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

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



p.sort()

ans = 0

for i in range(K):

    ans += p[i]

print(ans)
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()
ans = 0
for i in range(K):
    ans += p[i]
print(ans)

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

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