N,K=[int(i) for i in input().split()]
P=[int(i) for i in input().split()]
minS=float('inf')
for i in range(2**N):
  cmb=bin(i)[2:]
  cmb=(('0'*N)+cmb)[-N:]
  cmb=[int(i) for i in cmb]
  if sum(cmb)!=K:
    continue
  s=sum([P[i]*cmb[i] for i in range(N)])
  if minS > s:
    minS=s
print(minS)