

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

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



k = sorted(l)



ans = 0



for i in range(K):

    ans += k.pop()



print(ans)



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

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

l.sort(reverse = True)

ans = 0



for i in range(k):

    ans += l[i]

print(ans)

N, K = list(map(int, input().split()))
l = list(map(int, input().split()))
k = sorted(l)
ans = 0
for i in range(K):
    ans += k.pop()
print(ans)

n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = 0
for i in range(k):
    ans += l[i]
print(ans)

-N, K = list(map(int, input().split())) +n, k = list(map(int, input().split())) -k = sorted(l) +l.sort(reverse=True) -for i in range(K): -    ans += k.pop() +for i in range(k): +    ans += l[i]