N,K = (int(x) for x in input().split())

# plist = list(range(N))
# for i in range(N):
#     plist[i]=int(input())
plist = list(range(N))
plist = (int(x) for x in input().split())

plist.sort()
print(sum(plist[:K]))