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

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



count=0

p.sort()

for i in range(k):

  count+=p[i]

  

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

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

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

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

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