n, k = int(input()), int(input())
lst = []
result = []
for i in range(n):
    lst.append(int(input()))
for i in range(k):
    temp = min(lst)
    result.append(temp)
    lst.remove(temp)
print(sum(result))