length= int(input())
num=int(input())
i=0
j=0
p=0
fruits=[]
for i in range(length):
	fruits.append(int(input())
fruits.sort()
for j in range(num):
	p+=fruits[j]
print(p)
# for x in fruits:
# 	print(x)