import itertools
[N, K] = [int(i)  for i in input().split()]
price = [int(i)  for i in input().split()]
select_sum = sum(price)
for select  in itertools.combinations(price, K):
    if sum(select) < select_sum:
        select_sum = sum(select)
print(select_sum)