inp1 = eval(input())

inp2 = eval(input())



lists1 = inp1.split()

lists2 = inp2.split()



N = int(lists1[0])

K = int(lists1[1])

values = sorted([int(i) for i in lists2])



result = sum(values[:K])



print(result)

n, k = list(map(int, input().split()))

p = list(map(int, input().split()))



p.sort()



ans = 0

for i in range(k):

  ans += p.pop(0)

  

print(ans)
inp1 = eval(input())
inp2 = eval(input())
lists1 = inp1.split()
lists2 = inp2.split()
N = int(lists1[0])
K = int(lists1[1])
values = sorted([int(i) for i in lists2])
result = sum(values[:K])
print(result)

n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
ans = 0
for i in range(k):
    ans += p.pop(0)
print(ans)

-inp1 = eval(input()) -inp2 = eval(input()) -lists1 = inp1.split() -lists2 = inp2.split() -N = int(lists1[0]) -K = int(lists1[1]) -values = sorted([int(i) for i in lists2]) -result = sum(values[:K]) -print(result) +n, k = list(map(int, input().split())) +p = list(map(int, input().split())) +p.sort() +ans = 0 +for i in range(k): +    ans += p.pop(0) +print(ans)