import numpy as np
from itertools import combinations
n,k = map(int,input().split())
if n==1:
    print(int(input()))
else:
    lis = input().split()
    total =np.inf

    for i in combinations(lis,k):
        ml =0

        for a in i:

            ml += int(a)

        total = min(total,ml)


    print(total)