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

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

p.sort()



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

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

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

p.sort()

total = 0

for i in range(k):

  total += p[i]

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

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

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