import itertools
 
S = list(map(int, input().strip().split()))
N = S[0]
K = s[1]
p = list(map(int, input().strip().split()))
lists = []
for l in itertools.combinations(p, K):
  sums = sum(list(l))
  lists.append(sums)
 
print(min(lists))
