N = input()
K = input()
lists = []
B = 0

for i in range(int(N)):
    A = input()
    lists.append(int(A))
    #print(A)

lists.sort()
#print(lists)

for j in range(int(K)):
  B += int(lists[j])
 
print(B)