n,k=input().split()

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

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

A = sorted(A, reverse = True)



ans = 0

for i in range(K):

    ans += A[i]



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

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
ans = 0
for i in range(K):
    ans += A[i]
print(ans)

-n, k = input().split() -print((sum(sorted(list(map(int, input().split())))[: -int(k) - 1 : -1]))) +N, K = list(map(int, input().split())) +A = list(map(int, input().split())) +A = sorted(A, reverse=True) +ans = 0 +for i in range(K): +    ans += A[i] +print(ans)