a=input().split()

b=input().split()

N=int(a[0])

K=int(a[1])

c=[]

s=0



for i in range(N):

 l=int(b[i])

 c.append(l)

c.sort(reverse=True)

for i in range(K):

 s +=c[i]

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

l = input().split()

sum = 0



for i in range(N):

  l[i] = int(l[i])

l.sort()



for i in range(K):

  sum += l.pop(-1)

print(sum)
a = input().split()
b = input().split()
N = int(a[0])
K = int(a[1])
c = []
s = 0
for i in range(N):
    l = int(b[i])
    c.append(l)
c.sort(reverse=True)
for i in range(K):
    s += c[i]
print(s)

N, K = list(map(int, input().split()))
l = input().split()
sum = 0
for i in range(N):
    l[i] = int(l[i])
l.sort()
for i in range(K):
    sum += l.pop(-1)
print(sum)

-a = input().split() -b = input().split() -N = int(a[0]) -K = int(a[1]) -c = [] -s = 0 +N, K = list(map(int, input().split())) +l = input().split() +sum = 0 -    l = int(b[i]) -    c.append(l) -c.sort(reverse=True) +    l[i] = int(l[i]) +l.sort() -    s += c[i] -print(s) +    sum += l.pop(-1) +print(sum)