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):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, k = map(int, input().split())
l = readints()
ll = sorted(l)
sum = 0
for i in range(k):
    sum += ll[-(i+1)]
print(sum)

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):
import sys
import math
import bisect

def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    print(sum(A[-m:]))

if __name__ == "__main__":
    main()

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

print(sum(l[:k]))

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

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

print(ans)

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

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

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

l = list(sorted(l, reverse=True))
s = 0
for a in range(0, k):
    s += l[a]

print(s)

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):
_, K = map(int, input().split())
L = list(map(int, input().split()))

print(sum(sorted(L, reverse=True)[:K]))

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


if __name__ == "__main__":
    main()

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

L2 = sorted(L, reverse = True)

print(sum(L2[:K]))

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

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

Solution (Python):
N, K = map(int, input().split())
data = [int(i) for i in input().split()]
D = sorted(data, reverse=True)
ma = 0

for i in range(K):
    ma += D[i]

print(ma)

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

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

A = list(map(int,input().split()))
A.sort()

tar = A[-K:]
tar_sum = sum(tar)
print(tar_sum)

Solution (Python):
n, k = map(int, input().split())
l = [int(x) for x in 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 = sorted(map(int, input().split()), reverse=True)

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

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

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

l.sort(reverse=True)
answer = 0

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

print(answer)

Solution (Python):

import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7


N, K = ri_()
print(sum(sorted(ri_(), reverse=True)[:K]))

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 = sum(l[:K])
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

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

print(sum(l[:K]))

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

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

l = sorted(l, reverse=True)

print(sum(l[:k]))

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

l = sorted(l, reverse=True)
score = 0

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

print(score)

Solution (Python):
n,k = map(int, input().split())
ls = sorted(list(map(int, input().split())), reverse = True)
print(sum(ls[: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())
ans=0
l=sorted(list(map(int,input().split())),reverse=True)
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()

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

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

Solution (Python):
n, k = map(int, input().split())
m = sorted(map(int, input().split()))[::-1]
print(sum(m[: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())
*A, = map(int, input().split())

dp = [[-1]*(K + 1) for _ in range(N + 1)]
for j in range(K + 1):
    dp[0][j] = 0

for i in range(N):
    for j in range(K + 1):
        if j >= 1:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - 1] + A[i])
        else:
            dp[i + 1][j] = dp[i][j]
            
print(dp[N][K])

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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, K = MAP()
l = LIST()

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n,k=MI()
ls=sorted(LI(),reverse=True)
ans=0
for i in range(k):
    ans+=ls[i]
print(ans)

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

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

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

Solution (Python):
import sys
from io import StringIO
import unittest


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

    Lsort = sorted(L, reverse=True)
    re = 0
    for i in range(k):
        re += Lsort[i]

    print(re)
resolve()

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

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

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int,_in[0].split(' ')))
    l_arr = list(map(int,_in[1].split(' ')))
    
    l_arr.sort(reverse=True)
    cnt = sum(l_arr[:K])
    
    print(cnt)

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())
llist=list(map(int,input().split()))
llist.sort(reverse=True)

print(sum(llist[: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 = sorted(list(map(int, input().split())), reverse = True)
print(sum(l[0:k]))

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

print(ans)

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

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

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

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

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

Solution (Python):
n, k = map(int, input().split());print(sum(sorted([int(x) for x in input().split()], reverse=True)[: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):



import sys





def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(allNumber, selectNum, eachLength):
    result = 0
    
    sortedStickLength = sorted(eachLength, reverse=True)
    
    for j in range(0, selectNum, +1):
        result = result + sortedStickLength[j]
    return result


if __name__ == "__main__":
    N, K = MI()
    StickList = LI()
    print("{}".format(solver(N, K, StickList)))

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

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

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

List = list(map(int,input().split()))
List = sorted(List)
for i in range(N-K):
  del List[0]

print(sum(List))

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):
k=int(input().split()[1])
print(sum(sorted([int(x) for x in 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())
ln = list(map(int, input().split()))
ln.sort(reverse=True)
print(sum(ln[:k]))

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

Solution (Python):
N,K=map(int,input().split())
m=list(map(int,input().split()))
m.sort(reverse=True)
print(sum(m[: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 = sorted(l)
l = l[::-1]
print(sum(l[:k]))

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


if '__main__' == __name__:
    resolve()

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

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

Solution (Python):
N, K = map(int, input().split())
sticks = sorted([int(s) for s in input().split()], reverse=True)
snake = [l for i, l in enumerate(sticks) if i < K]
print(sum(snake))

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

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

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

Solution (Python):



import sys





def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(selectNum, snakeLongList):
    result = 0
    sortedSnakeLongList = sorted(snakeLongList, reverse=True)
    for j in range(0, selectNum, +1):
        result = result + sortedSnakeLongList[j]
    
    return result


if __name__ == "__main__":
    _, K = MI()
    LongI = LI()
    print("{}".format(solver(K, LongI)))

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

def main():
    N, K = map(int, readline().rstrip().split())
    L = list(map(int, readline().rstrip().split()))
    L.sort(reverse=True)
    print(sum(L[:K]))
    

if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())
l = sorted(list(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(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, = map(int, input().split())

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

Solution (Python):
x, y = map(int,input().split())
li = list(map(int,input().split()))
li.sort(reverse=True)

print(sum(li[:y]))

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

Solution (Python):
N,K=map(int,input().split())
L=list(map(int,input().split()))
L.sort();
ans = int(0)
for i in range(N-K,N):
	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[:k]))

Solution (Python):
N,K=map(int,input().split())
L=list(map(int,input().split()))
L.sort();
ans = int(0)
for i in range(N-K,N):
	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):
from sys import stdin
import math

[N, K] = list(map(int, stdin.readline().rstrip().split()))
l = list(map(int, stdin.readline().rstrip().split()))
l_sorted = sorted(l, reverse=True)

total_length=0
for i in range(K):
    total_length += l_sorted[i]

print(total_length)

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()))
L.sort(reverse = True)
print(sum(L[:K]))

Solution (Python):
a,b = map(int,input().split())
num = list(map(int,input().split()))   
num.sort()
num=num[-b:]

print(sum(num))

Solution (Python):



import sys





def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(selectNum, barLongth):
    result = 0
    barLongth.sort(reverse=True)
    
    
    j = 0
    while j < selectNum:
        result = result + barLongth[j]
        j = j + 1
    return result


if __name__ == "__main__":
    _, K = MI()  
    LII = LI()
    print("{}".format(solver(K, LII)))

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 = [int(i) for i in input().split()]
sorted_L = sorted(L, reverse=True)

max = 0
for i in range(K):
    max += sorted_L[i]

print(max)

Solution (Python):
N,K,*L = map(int,open(0).read().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)
m=l[:k]
print(sum(m))

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())), reverse = True)
print(sum(l[:k]))

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

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

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

print(sum(a[:k]))

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

b=sum(a)
for i in range(n-k):
    b-=a[i]

print(b)

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

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

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

ans = list(sorted(L))[::-1]
ans = sum(ans[0:k])
print(ans)

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

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

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

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

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

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

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

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

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())
lll = list(map(int, input().split()))
lll.sort()
print(sum(lll[n - k:n]))

Solution (Python):


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

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

M = 0

L.sort(reverse=True)

for i in range(K):
    M += L[i]

print(M)

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

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

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

l = sorted(l)[::-1]

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)
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=sorted(l)[::-1]

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

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

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())
length = list(map(int, input().split()))

length = sorted(length, reverse=True)

print(sum(length[:K]))

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

Solution (Python):
n,k=map(int,input().split())
a=sorted(map(int,input().split()),reverse=True)
print(sum(a[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 = [int(s) for s in input().split()]
l.sort()
print(sum(l[k * (-1):]))

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

l.sort(reverse=True)

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 = sorted(l,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):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    L = sorted(il())[::-1]
    print(sum(L[0:K]))


if __name__ == '__main__':
    main()

Solution (Python):
tot,sel=(int(x) for x in input().split())
al=[]
aa=(int(x) for x in input().split())

for i in aa:
  al.append(i)

al.sort()  

print(sum(al[-sel:]))

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_ls = list(map(int, input().split()))

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

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

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

print(length)

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

l.sort()
ans=0

for i in range(k):
    ans+=l.pop()
    
print(ans)

Solution (Python):
import sys
 
N, K = map(int, sys.stdin.readline().split(" "))
L = sorted(list(map(int, sys.stdin.readline().split(" "))), reverse=True)
print(sum(L[0:K]))

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

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 = sorted(list(map(int, input().split())), reverse=True)
ans = 0

for i in range(K):
    ans += L[i]

print(ans)

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

Solution (Python):
n, k = map(int, input().split())
print(sum(sorted(list(map(int, input().split())), reverse=True)[: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 = [int(i) for i in 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())
a=sorted(list(map(int,input().split())),reverse=True)
print(sum(a[: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()))
l.sort()
l.reverse()
length = 0
for i in range(k):
    length += l[i]
print(length)

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

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    L = [int(l) for l in input().split()]
    L.sort(reverse = True)
    print(sum(L[:K]))

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
def ABC67_B():
    N, K = LI()
    L = LI()
    L.sort(reverse=True)
    ans = sum(L[:K])
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    ABC67_B()

"""

"""

Solution (Python):


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

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

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()))
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(map(int,input().split()))[n-k:]))

Solution (Python):
def resolve():

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

    print(sum(L[:K]))

resolve()

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

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())
*L,=map(int, input().split())
L.sort(reverse=True)
print(sum(L[:K]))

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

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 = map(int, input().split())
a = sorted(list(map(int,input().split())))[::-1]
print(sum(a[: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):
def main():
    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]))


if __name__ == '__main__':
    main()