n, k = input().split()
lists = list(input().split())
for i in range(int(n)):
    lists[i] = int(lists[i])
lists.sort()
for i in range(int(k)):
  sum_fruit = sum_fruit + int(lists.pop(0))
print(str(sum_fruit))