N = int(input())
K = int(input())
prices = list()
for i in range(N):
    prices.append(int(input()))
sum = 0
for i in prices:
    x = min(prices)
    sum = sum + x
    prices.remove(x)
    K = K - 1
    if K == 0: break
print(sum)