n = int(input("enter n : "))
k =  int(input("enter k : "))
l = list([])
for i in range(n) : 
    x = int(input("enter x "))
    l.append(x)
l.sort()
sum =0 
for j in range(k) : 
    sum += l[j]
print(sum)