import sys
import itertools

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N, K = MI()
    p = LI()
    c = itertools.combinations(p, K)
    clist = list(c)
    cn = len(clist)

    for i in range(cn):
        sumi = int(sum(clist[i]))
        if i == 0:
            min =sumi
        if min > sumi:
            min = sumi

    print(min)
    #print(len(clist))
    #print(sum(clist[2]))



if __name__ == "__main__":
	main()