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

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

l.sort(reverse = True)

sum = 0



for i in range(k):

    sum+=l[i]

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

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

l.sort(reverse = True)

ans = sum(l[:k])

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

n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = sum(l[:k])
print(ans)

-sum = 0 -for i in range(k): -    sum += l[i] -print(sum) +ans = sum(l[:k]) +print(ans)