import itertools
n, k = map(int, input().split())
p = list(map(int, input().split()))

min_ = float('inf')
combi = itertools.combinations(p, k)
for c in combi:
    min_ = min(min_, sum(c))
    
print(min_)