N, K = list(map(int, input().split()))

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



p.sort()

count = 0

for i in range(K):

    count += p[i]



print(count)
N, K = list(map(int, input().split()))

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

pin = p.sort()

print((sum(p[:K])))
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
count = 0
for i in range(K):
    count += p[i]
print(count)

N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
pin = p.sort()
print((sum(p[:K])))

-p.sort() -count = 0 -for i in range(K): -    count += p[i] -print(count) +pin = p.sort() +print((sum(p[:K])))