import sys



N, K = list(map(int, sys.stdin.readline().strip().split()))

P = list(map(int, sys.stdin.readline().strip().split()))



ans = 0

for i, p in enumerate(sorted(P)):

    if i == K:

        break

    ans += p



print(ans)
import sys



N, K = list(map(int, sys.stdin.readline().split()))

P = list(map(int, sys.stdin.readline().split()))



P.sort()

print((sum(P[0:K])))
import sys

N, K = list(map(int, sys.stdin.readline().strip().split()))
P = list(map(int, sys.stdin.readline().strip().split()))
ans = 0
for i, p in enumerate(sorted(P)):
    if i == K:
        break
    ans += p
print(ans)

import sys

N, K = list(map(int, sys.stdin.readline().split()))
P = list(map(int, sys.stdin.readline().split()))
P.sort()
print((sum(P[0:K])))

-N, K = list(map(int, sys.stdin.readline().strip().split())) -P = list(map(int, sys.stdin.readline().strip().split())) -ans = 0 -for i, p in enumerate(sorted(P)): -    if i == K: -        break -    ans += p -print(ans) +N, K = list(map(int, sys.stdin.readline().split())) +P = list(map(int, sys.stdin.readline().split())) +P.sort() +print((sum(P[0:K])))