import itertools
N, K = map(int, input().split())
P = list(map(int, input().split()))
B = list(itertools.combinations(P, K))
ans = []
if N == 1:
    print(P[0])
    exit(0)
for b in B:
    ans.append(sum(b))
print(min(ans))