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

p = [int(i) for i in input().split()]

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

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

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

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

-p = [int(i) for i in input().split()] +p = list(map(int, input().split()))