Problem:
 Score : 200 points    Problem Statement Snuke has N sticks.
The length of the i -th stick is l_i .  Snuke is making a snake toy by joining K of the sticks together.  The length of the toy is represented by the sum of the individual sticks that compose it.
Find the maximum possible length of the toy.      Constraints  1 \leq K \leq N \leq 50  1 \leq l_i \leq 50  l_i is an integer.         Input Input is given from Standard Input in the following format:  N  K  l_1  l_2  l_3  ...  l_{N}       Output Print the answer.        Sample Input 1 5 3
1 2 3 4 5      Sample Output 1 12  You can make a toy of length 12 by joining the sticks of lengths 3 , 4 and 5 , which is the maximum possible length.       Sample Input 2 15 14
50 26 27 21 41 7 42 35 7 5 5 36 39 1 45      Sample Output 2 386

Solution (Python):
n,k = 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)

Solution (Python):
n, k = map(int, input().split())
l = list(map(int, input().split()))

print(sum(sorted(l, reverse=True)[:k]))

Solution (Python):
N,K = map(int,input().split())
l = list(map(int,input().split()))
a = 0

while K > 0:
    a += max(l)
    l.pop(l.index(max(l)))
    K -= 1
print(a)

Solution (Python):
N, K =map(int, input().split())
L = list(map(int,input().split()))
L.sort(reverse = True)
print(sum(L[:K]))

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

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

Solution (Python):
N, K = map(int, input().split())
L = list(map(int, input().split()))
L.sort(reverse=True)
length = 0
for k in range(K):
    length += L[k]
print(length)

Solution (Python):
n,k,*l=map(int,open(0).read().split());print(sum(sorted(l)[n-k:]))

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

Solution (Python):
N,K = map(int, input().split())
ln = list(map(int, input().split()))
ans = 0
for i in range(K):
  ans += ln.pop(ln.index(max(ln)))
print(ans)

Solution (Python):
N,K,*L=map(int,open(0).read().split());print(sum(sorted(L)[-K:]))

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

Solution (Python):
n, k = map(int,input().split())
print(sum(sorted(list(map(int,input().split())),reverse=True)[0:k]))

Solution (Python):
n, k = map(int, input().split())
ls = list(map(int, input().split()))
ls.sort()
ls = ls[::-1]
ans = 0
for i in range(k):
    ans += ls[i]
print(ans)

Solution (Python):
import numpy as np

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

ls = input().split()
ls_arr = np.zeros(N)
for i in range(N):
  ls_arr[i] = int(ls[i])

ls_arr = np.sort(ls_arr)[::-1]

ans = int(ls_arr[:K].sum())

print(ans)

Solution (Python):
N,K = map(int,input().split())
l = sorted(list(map(int,input().split())),reverse = True)
print(sum(l[:K]))

Solution (Python):
N, K = map(int, input().split())
*L,    = map(int, input().split())

L.sort()


print(sum(L[-K:]))

Solution (Python):
n, k = map(int, input().split())
l = list(map(int, input().split()))

l.sort()
l.reverse()

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

print(ans)

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

Solution (Python):
N, K = map(int, input().split())

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

print(sum(L[N-K:]))

Solution (Python):
N, K = map(int, input().split())
l = list(map(int,input().split()))

l.sort(reverse=True)
print(sum(l[0:K]))

Solution (Python):
n,k = map(int,input().split())
l = list(map(int,input().split()))
ans=0

l.sort()
for i in range(k):
    ans+=l[n-i-1]
print(ans)

Solution (Python):
N, K = map(int, input().split())
L = list(map(int, input().split()))

L.sort(reverse=True)

print(sum(L[:K]))

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    l = sorted(list(map(int, input().split())), reverse=True)

    print(sum(l[:K]))



if __name__ == "__main__":
    main()

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

Solution (Python):
N, K = map(int, input().split(" "))

arr = list(map(int, input().split(" ")))
arr.sort(reverse = True)

length = 0

for i in range(K):
  length += arr[i]
print(length)

Solution (Python):
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = []

for i in range(K):
    ans.append(l[i])
    
print(sum(ans))

Solution (Python):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
print(sum(sorted(arr, reverse=True)[0:k]))

Solution (Python):

N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
print(sum(l[:K]))

Solution (Python):
n, k = map(int,input().split())
l = list(map(int,input().split()))
l.sort(reverse = True)

print(sum(l[:k]))

Solution (Python):
n, k = map(int, input().split())
l = list(map(int, input().split()))

l.sort(reverse=True)

print(sum(l[:k]))

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

Solution (Python):
n,k = map(int, input().split())
l = sorted(map(int, input().split()))
print(sum(l[-k::]))

Solution (Python):
n, k = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse=True)

ans = l[:k]
print(sum(ans))

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

print(sum_l)

Solution (Python):
N, K = map(int, input().split())
L = list(map(int, input().split()))

L = sorted(L)[::-1]
print(sum(L[:K]))

Solution (Python):
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, k = na()
lll = na()
list.sort(lll, reverse=True)
print(sum(lll[:k]))

Solution (Python):
n, k = [int(num) for num in input().split()]
list = [int(num) for num in input().split()]

list.sort(reverse=True)
print(sum(list[:k]))

Solution (Python):
n, k = map(int, input().split())
print(sum(sorted(list(map(int, input().split())), reverse=True)[:k]))

Solution (Python):
n,k =  [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()
print(sum(l[-k:]))

Solution (Python):
N, K = map(int, input().split())
L = sorted(list(map(int, input().split())),reverse=True)
print(sum(L[:K]))

Solution (Python):
n,k=map(int,input().split())
L=list(map(int,input().split()))

L.sort()

print(sum(L[-k:]))

Solution (Python):

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

L.sort(reverse=1)
print(sum(L[:k]))

Solution (Python):
N, K = map(int, input().split())
L = sorted(list(map(int, input().split())), reverse=True)
print(sum(L[:K]))

Solution (Python):
n, k = map(int, input().split())
l = map(int, input().split())
s = sorted(l)[::-1]
print(sum(s[:k]))

Solution (Python):
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, K = map(int, input().split())
        l = list(map(int, input().split()))

        l.sort(reverse=True)
        print(sum(l[:K]))


if __name__ == '__main__':
    AtCoder().main()

Solution (Python):
n,k=map(int,input().split())
l = sorted(list(map(int, input().split())),reverse=True)

print(sum(l[:k]))

Solution (Python):
N,K=map(int,input().split());print(sum(sorted(map(int,input().split()))[-K:]))

Solution (Python):
N,K=map(int,input().split())
l=list(map(int,input().split()))
print(sum(sorted(l, reverse=True)[0:K]))

Solution (Python):
N,K = map(int, input().strip().split(' '))
L = sorted(list(map(int, input().strip().split(' '))))
print(sum(L[-K:]))

Solution (Python):
n,k=map(int,input().split())
l=list(map(int,input().split()))

l.sort()
l.reverse()


ans=0


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

Solution (Python):
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
l.reverse()

ans=0

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

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)
ans = 0
for k in range(K):
    ans += A[k]
print(ans)

Solution (Python):
n,k = map(int,input().split())
print(sum(sorted(list(map(int,input().split())),reverse=1)[:k]))

Solution (Python):
N, K = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse = True)
print(sum(l[:K]))

Solution (Python):
N,K = map(int,input().split())
l = sorted(list(map(int,input().split())))
print(sum(l[-K:]))

Solution (Python):
n, k = map(int, input().split())
l = [int(i) for i in input().split()]

l.sort(reverse=True)
print(sum(l[:k]))

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

Solution (Python):
N, K = map(int,input().split())

a = sorted(map(int,input().split()))

a.reverse()

length = 0

for x in range(K):
    length += a[x]
    
print(length)

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

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

Solution (Python):
n,k = map(int,input().split())
lns=sorted(list(map(int,input().split())),reverse=True)
he = 0
for i in range(k):
  he+=lns[i]

print(he)

Solution (Python):
def main():
    N, K = map(int, input().split())
    L = [int(l) for l in input().split()]
    L.sort(reverse = True)
    return sum(L[:K])


if __name__ == '__main__':
    print(main())

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

Solution (Python):
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())))
print(sum(l[-k:]))

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

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

Solution (Python):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)

print(sum(l[:k]))

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

Solution (Python):
n,k=map(int,input().split())
l=[int(i) for i in input().split()]

l.sort()
l.reverse()
print(sum(l[:k]))

Solution (Python):
n,k=map(int,input().split())
Is=list(map(int,input().split()))
Is.sort()

print(sum(Is[-k:]))

Solution (Python):


from functools import reduce
from operator import add

n, k = map(int, input().split())
sticks = list(map(int, input().split()))
sticks.sort(reverse = True)
print(reduce(add, sticks[:k]))

Solution (Python):
import sys
N, M = map(int, sys.stdin.readline().rstrip().split())
l = sorted(map(int, sys.stdin.readline().rstrip().split()), reverse = True)
print(sum(l[:M]))

Solution (Python):
N, K = map(int,input().split())
ls = list(map(int, input().split()))
ls.sort(reverse=True)
print(sum(ls[:K]))

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

Solution (Python):
N, K = map(int, input().split())
l = [int(s) for s in input().split()]
l.sort()
print(sum(l[-K:]))

Solution (Python):
_, K = 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)

Solution (Python):
n, k = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
l.sort(reverse=True)
print(sum(l[:k]))

Solution (Python):
N,K=map(int,input().split())
l=sorted(list(map(int,input().split())))
ans=0
for i in range(1,K+1):
  ans+=l[-i]
print(ans)

Solution (Python):
n,l=map(int,input().split())

r=sorted(list(map(int,input().split())))[::-1]
print(sum(r[:l]))

Solution (Python):
N, K = map(int, input().split())
ls = list(map(int, input().split()))
ls.sort(reverse=True)
r = sum(ls[0:K])
print(r)

Solution (Python):
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse = True)

print (sum(l[:K]))

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

Solution (Python):
i, j = [input() for x in range (2)]
K, N = [int(y) for y in i.split(' ')]
arr = sorted([int(y) for y in j.split(' ')], reverse=True)

print(sum(arr[:N]))

Solution (Python):
nk = input().split()
n = int(nk[0])
k = int(nk[1])
li = input().split()

for i in range(n):
	li[i] = int(li[i])

li = sorted(li, reverse = True)

ans = 0
for i in range(k):
	ans += li[i]

print(ans)

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

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

Solution (Python):
L,R = map(int,input().split())
hoge = list(map(int, input().split()))
print(sum(sorted(hoge)[::-1][:R]))

Solution (Python):



import sys
input = sys.stdin.readline


def main():
    n, k = 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)


if __name__ == '__main__':
    main()

Solution (Python):
n,k=map(int,input().split())
L=map(int,input().split())
print(sum(sorted(L)[k*(-1):]))

Solution (Python):
n, k = map(int, input().split())
l = list(map(int, input().split()))

l.sort()
l.reverse()
ans = 0
for i in range(0, k):
    ans += l[i]
print(ans)

Solution (Python):

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

L.sort(reverse=True)
print(sum(L[0:K]))

Solution (Python):
N, K = map(int, input().split())
l = list(sorted(map(int, input().split())))
print(sum(l[-K:]))

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

Solution (Python):
z=list(map(int,input().split()))
a=sorted(list(map(int,input().split())))
print(sum(a[-z[1]:-1])+a[-1])

Solution (Python):
(n, k) = (int(tok) for tok in input().split())
sticks = sorted(int(tok) for tok in input().split())

print(sum(sticks[n - k:]))

Solution (Python):
N, K = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
a.reverse()

num = 0
result = 0


for x in a:
    num = num +1
    result = result + x
    if num == K:
        print(result)

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

Solution (Python):
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)

ans = 0
for i in range(k):
    ans += a[i]
print(ans)

Solution (Python):
n,k=input().split()
n,k=int(n),int(k)

l=sorted([int(i) for i in input().split()],reverse=True)

print(sum(l[:k]))

Solution (Python):
N, K = list(map(int, input().split()))
l = list(map(int, input().split()))

ls = sorted(l)[::-1]
sum = 0
for k in ls[:K]:
    sum += k
print(sum)

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

Solution (Python):
n, k = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse=True)
ans = 0

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

Solution (Python):



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


l.sort(reverse=True)


print(sum(l[0:K]))

Solution (Python):
N, K = map(int, input().split())
l = sorted(list(map(int, input().split())))

print(sum(l[-K:]))

Solution (Python):
n, k = map(int, input().split())
l = sorted(map(int, input().split())) [::-1]
print(sum(l[:k]))

Solution (Python):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
print(sum(l[n-k:]))

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

Solution (Python):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
print(sum(l[-k:]))

Solution (Python):
n,k = map(int,input().split())
l = [int(i) for i in input().split()]
l.sort()
ans = 0
for i in range(1,k+1):
    ans += l[-i]
print(ans)

Solution (Python):
num, req_num = map(int,input().split())
num_array    = sorted(list(map(int,input().split())),reverse=True)
result = 0

for i in range(req_num):
    result += num_array[i]

print(result)

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

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

Solution (Python):
N, K = map(int, input().split())
l = [int(i) for i in input().split()]

l.sort()
print(sum(l[-K:]))

Solution (Python):
n,k = map(int, input().split())
l = list(map(int, input().split()))
x = sorted(l)
print(sum(x[n-k:]))

Solution (Python):
n,k = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]

array.sort()

sum = 0
for i in range(k):
  sum += array[-(i+1)]

print(sum)

Solution (Python):
n, k = map(int, input().split())
print(sum(sorted(map(int, input().split()), reverse=True)[:k]))

Solution (Python):
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = 0

a.sort(reverse=True)
for i in range(k):
  b += a[i]
  
print(b)

Solution (Python):
N,K=map(int,input().split())
L=list(map(int,input().split()))

r_L=sorted(L)[::-1]

print(sum(r_L[:K]))

Solution (Python):
N,K = map(int,input().split())
li = list(map(int,input().split()))
li.sort(reverse = True)
total = 0
for i in li[:K]:
  total += i
  
print(total)

Solution (Python):
n,k=map(int,input().split())
li=list(map(int,input().split()))

li.sort(reverse=True)
ans=0
for i in range(k) :
  ans+=li[i]
  
print(ans)

Solution (Python):
n,k = map(int,input().split())
ln = map(int,input().split())
print(sum(list(reversed(sorted(ln)))[:k]))

Solution (Python):
N,K = map(int,input().split(' '))
L = sorted(map(int,input().split(' ')))
print(sum(L[N-K:]))

Solution (Python):
N, K = map(int, input().split())
l = list(map(int, input().split()))
result = 0
for _ in range(K):
    m = max(l)
    result += m
    l.remove(m)
print(result)

Solution (Python):



N, K = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse = True)



print(sum(l[:K]))

Solution (Python):
N, K = map(int, input().split())
print  (sum(sorted(map(int, input().split()))[-K:]))

Solution (Python):
N, K = map(int, input().split())
l = list(map(int, input().split()))

l.sort(reverse = True)
print (sum(l[0:K]))

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

Solution (Python):
length = 0
N,K = map(int,input().split())
l_list = list(map(int,input().split()))
l_list.sort()

for _ in range(K):
  length+=l_list.pop()

print(length)

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

Solution (Python):

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

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

Solution (Python):
s, k = map(int,input().split())
sticks = sorted([int(i) for i in input().split()],reverse = True)
result_sum = 0

for j in range(k):
    result_sum += sticks[j]

print(result_sum)

Solution (Python):

def main():


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

    srtList=sorted(snakeList,reverse=True)
    print(sum(srtList[0:K]))





    
if __name__== "__main__":
    main()

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, K: int, l: "List[int]"):
    l.sort(reverse=True)
    print(sum(l[:K]))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    l = [int(next(tokens)) for _ in range(N)]  
    solve(N, K, l)


if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse=True)
print(str(sum(l[0:K])))

Solution (Python):
n, k = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
print(sum(sorted(l, reverse=True)[:k]))

Solution (Python):
N, K = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort(reverse=True)
sum = 0
for i in range(0, K):
    sum += l[i]
print(sum)

Solution (Python):
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)

ans = sum(l[:K])
print(ans)

Solution (Python):
n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
print(sum(l[-k:]))

Solution (Python):
n, k = map(int, input().split())
l = list(map(int, input().split()))

l.sort(reverse=True)
print(sum(l[:k]))

Solution (Python):
N,K = map(int,input().split())
l = list(map(int,input().split()))

l.sort()
l.reverse()

x = 0
for i in range(K):
    x += l[i]
print(x)

Solution (Python):

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

Solution (Python):
n, k = map(int, input().rstrip("\n").split())
sticks = sorted(map(int, input().rstrip("\n").split()), reverse=True)

print(sum(sticks[:k]))

Solution (Python):
n, k = map(int, input().split())
stick_list = list(map(int, input().split()))
stick_list.sort()
selections = stick_list[-k:]

print(sum(selections))

Solution (Python):
N,K,*l = map(int, open(0).read().split())
print(sum(sorted(l, reverse=True)[:K]))

Solution (Python):
a,b = list(map(int, input().split()))
l = sorted(list(map(int, input().split())), reverse=True)

print(sum(l[:b]))

Solution (Python):
a,b = list(map(int, input().split()))
l = list(map(int, input().split()))
ll = sorted(l, reverse=True)
print(sum(ll[:b]))

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

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

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

Solution (Python):
n,k = map(int,input().split())
l = [int(_) for _ in input().split()]
l.sort(reverse=True)
print(sum(l[:k]))

Solution (Python):
N,K=[int(x) for x in input().split()]
lN=[int(x) for x in input().split()]
lN.sort()
print(sum(lN[N-K:]))

Solution (Python):
x,y = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
ans = 0
for i in range(1,y+1):
  ans += a[-i]
print(ans)

Solution (Python):
N, K = map(int, input().split())
l_list = list(map(int, input().split()))

l_list_sorted = sorted(l_list, reverse=True)

print(sum(l_list_sorted[0:K]))

Solution (Python):
N, K = map(int, input().split())
l = list(map(int, input().split()))

l.sort(reverse=True)
print(sum(l[:K]))

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

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

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

Solution (Python):
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)

Solution (Python):
n,k=map(int,input().split())

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

l_max=sorted(l,reverse=True)[:k]
print(sum(l_max))

Solution (Python):
n,k = map(int,input().split())
li = list(map(int,input().split()))
li2 = li.sort(reverse = True)
print(sum(li[:k]))

Solution (Python):
N, K = map(int, input().split())

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

lLst.sort(reverse=True)
ans = 0
for i in range(K):
    ans += lLst[i]

print(ans)

Solution (Python):
n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
print(sum(l[-1*k:]))

Solution (Python):

n, k = [int(el) for el in input().split(' ')]
L = sorted([int(l) for l in input().split(' ')])

print(sum(L[-k:]))

Solution (Python):
n, k = map(int, input().split())
l_list = list(map(int, input().split()))
new_list = []
for i in range(k):
    max_value = l_list.pop(l_list.index(max(l_list)))
    new_list.append(max_value)
print(sum(new_list))

Solution (Python):
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort(reverse = True)

print(sum(l[:k]))

Solution (Python):
N, K = map(int, input().split())
sticks = list(map(int, input().split()))
sticks.sort(reverse=True)
print(sum(sticks[:K]))

Solution (Python):

import sys, math, fractions, itertools


def solve(N: int, K: int, l: "List[int]"):
    l = sorted(l)
    print(sum(l[N-K:]))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    l = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, K, l)

if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())
L = map(int, input().split())
print(sum(sorted(L, reverse=True)[:K]))

Solution (Python):


def main(N,K,L):
    L = sorted(L,reverse=True)
    ans = 0
    for i in range(K):
        ans += L[i]
    print(ans)

if __name__ == '__main__':
    N,K = map(int, input().split())
    L = [int(l) for l in input().split()]
    main(N,K,L)

Solution (Python):

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

l.sort()
l.reverse()

s=0

for i in range(K):
    s += l[i]

print(s)

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 




 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,K = inputMap()
    l = inputList()
    
    l.sort()
    ll = l[::-1]
    
    ans = 0
    
    for i in range(K):
        
        ans += ll[i]
    
    print(ans)
        
if __name__ == "__main__":
	main()

Solution (Python):
n, k = map(int, input().split())
l = sorted(list(map(int, input().split())))
print(sum(l[n-k:]))

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

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

Solution (Python):
N,K = list(map(int,input().split()))
l = sorted(list(map(int,input().split())),reverse=True)
print(sum(l[:K]))

Solution (Python):
n, k = 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)

Solution (Python):
N, K = 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)

Solution (Python):
N,K = map(int,input().split())
L = list(map(int,input().split()))
L.sort(reverse=True)
A = []
for i in range(K):
  A.append(L[i])

print(sum(A))

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

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

Solution (Python):
n, k = map(int, input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)

ans = 0
for i in range(k):
  ans += a[i]

print(ans)

Solution (Python):
N,K = map(int, input().split())
l = [int(i) for i in input().split()]

ls = sorted(l , reverse= True)

count = 0
for i in range(K):
  count += ls[i]
print(count)

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

Solution (Python):
n, k = map(int, input().split())
l = list(map(int, input().split()))

l.sort(reverse=True)
result = 0

for i in range(k):
    result += l[i]

print(result)

Solution (Python):
N,K = map(int, input().split())
l_list= list(map(int, input().split()))

l_list.sort()
print(sum(l_list[-K:]))

Solution (Python):
N,K=input().split()
l=list(map(int,input().split()))
K=int(K)
l.sort()
l.reverse()
S=0
for i in range(K):
    S=S+l[i]
print(S)

Solution (Python):
N,K = [int(i) for i in input().split()]
l = [int (i) for i in input().split()]
l_sort = sorted(l,reverse = True)
sum_l = 0
for i in range(K):
    sum_l += l_sort[i]
print(sum_l)

Solution (Python):
N,K=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)[:K]
print(sum(l))

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, b = LI()
    if not (a % 3 and b % 3 and (a + b) % 3):
        print("Possible")
    else:
        print("Impossible")
    return


def B():
    k, n = LI()
    l = LI()
    l.sort(reverse = True)
    print(sum(l[:n]))
    return


def C():
    return


def D():
    return


if __name__ == '__main__':
    B()

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

Solution (Python):
inp = list(map(int, input().split()))
N = inp[0]
K = inp[1]
lengs = list(map(int, input().split()))
lengs.sort(reverse=True)
result = 0

for i in range(K):
    result += lengs[i]

print(result)

Solution (Python):
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = 0

for i in range(N):
    if K != 0:
        ans += l[i]
        K -= 1
    elif K == 0:
        break
print(ans)

Solution (Python):
n, k = map(int, input().split())
li = sorted(list(map(int, input().split())))
print(sum(li[n - k:]))

Solution (Python):
a, b = map(int, input().split())
c = list(map(int ,input().split()))
c = sorted(c, reverse=True)
print(sum([c[i] for i in range(b)]))

Solution (Python):
n,k=map(int,input().split())
print(sum(sorted(list(map(int,input().split())),reverse=True)[:k]))