import collections

s = [int(i) for i in input().split(" ")]
print(s)
p = [int(i) for i in input().split(" ")]
print(p)
p.sort()
print(p)
a = []

for i in range(0,s[1]):
	a.append(p[i])
print(sum(a))
