init = input().split()
N = int(init[0])
K = int(init[1])

prices = [int(input()) for i in range(N)]
prices.sort()

sum = 0
for i, ele in enumerate(prices):
  if i == K:
    break
  else
  	sum = sum + ele
print(sum)