import itertools
N, K = map(int, input().split())
p = [int(n) for n in input().split()]
p = list(itertools.combinations(p, K))
min = p[0][0] + p[0][1] + p[0][2]
for i in range(len(p)):
    a = p[i][0] + p[i][1] + p[i][2]
    if a < min:
        min = a
print(min)