import collections

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

for i in range(0,s[1]):
	a = p[i]
b = [int(b) for b in a]
print(sum(b))
