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

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



p.sort()

result = 0

for i in range(k):

    result += p[i]



print(result)



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

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



p.sort()



print((sum(p[:k])))

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

n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
print((sum(p[:k])))

-result = 0 -for i in range(k): -    result += p[i] -print(result) +print((sum(p[:k])))