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

print(( sum(sorted([ int(x) for x in input().split()], reverse = True)[:k]) ))
_, K = list(map(int, input().split()))

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



print((sum(sorted(L, reverse=True)[:K])))
n, k = list(map(int, input().split()))
print((sum(sorted([int(x) for x in input().split()], reverse=True)[:k])))

_, K = list(map(int, input().split()))
L = list(map(int, input().split()))
print((sum(sorted(L, reverse=True)[:K])))

-n, k = list(map(int, input().split())) -print((sum(sorted([int(x) for x in input().split()], reverse=True)[:k]))) +_, K = list(map(int, input().split())) +L = list(map(int, input().split())) +print((sum(sorted(L, reverse=True)[:K])))