N,K=map(int,input().split())
p=list(map(int,input().split()))
import itertools
l=list(itertools.combinations(p,K))
M=999999999999999999
for i in l:
    M=min(M,sum(i))
print(M)
    






        






    
















        


























            
    


    


    
    














    


    












