N, K, *p = map(int, open(0).read().split())

import itertools
lis = list(itertools.combinations(range(N), K))

mi = 0
for x in lis:
    cur = 0
    for pos in x:
        cur += p[pos]

    if mi == 0:
        mi = cur
    else:
        mi = min(mi, cur)

print(mi)