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)
n, k = list(map(int, input().split()))

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



p.sort()



ans = sum(p[:k])

  

print(ans)
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)

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

-ans = 0 -for i in range(k): -    ans += p.pop(0) +ans = sum(p[:k])