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

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

L = sorted(L)

ans = sum(L[len(L)- K :])

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

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



L.sort()

print((sum(L[N-K:])))
N, K = list(map(int, input().split()))
L = list(map(int, input().split()))
L = sorted(L)
ans = sum(L[len(L) - K :])
print(ans)

N, K = list(map(int, input().split()))
L = list(map(int, input().split()))
L.sort()
print((sum(L[N - K :])))

-L = sorted(L) -ans = sum(L[len(L) - K :]) -print(ans) +L.sort() +print((sum(L[N - K :])))