N, K = map(int,input().split())
prices = input().split()

for i in range(len(prices)):
    prices[i] = int(prices[i])

pricesSum = 0
while K > 0:
    newFruit = min(prices) 
    index = prices.index(newFruit)
    prices.pop(index)
    pricesSum += newFruit
    K -= 1