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

P=sorted(map(int,input().split()))

r=0

for i in range(K):

  r+=P[i]

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

P=sorted(map(int,input().split()))

print((sum(P[:K])))
N, K = list(map(int, input().split()))
P = sorted(map(int, input().split()))
r = 0
for i in range(K):
    r += P[i]
print(r)

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

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