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())
lst = [int(i) for i in input().split()]

lst.sort()
print(sum(lst[-k:]))

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

sort_l = sorted(l, reverse=True)
ans = 0

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

print(ans)

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

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

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

Solution (Python):
a,b = [int(i) for i in input().split()]

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

print(sum(l[a-b:]))

Solution (Python):

N,K = 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)

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

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

print(length)

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 = 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_asc = sorted(l, reverse=True)
ans = 0
for i in range(k):
    ans += l_asc[i]
print(ans)

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=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())

num = sorted(list(map(int, input().split())), reverse = True)

print(sum(num[:k]))

Solution (Python):


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

print(sum(list(reversed(sorted(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 = sorted(l)
S = 0
for _ in range(K):
    S += L[len(L)-1]
    L = L[0:len(L)-1]
print(S)

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

Solution (Python):
from sys import stdin

a,b = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

li.sort(reverse = True)

print(sum(li[:b]))

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

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

slice_k = s[:k]
print(sum(slice_k))

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

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

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

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

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

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

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

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

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

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

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

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

n_sort = sorted(n_list, reverse=True)
n_k = n_sort[0:k]
answer = sum(n_k)
print(answer)

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()))

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

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

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

sorted_Ls = sorted(Ls, reverse=True)
length_sum = 0
for k in range(K):
    length_sum += sorted_Ls[k]
print(length_sum)

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

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

main()

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 examB():
    N, K = LI()
    L = LI(); L.sort(reverse = True)
    ans = sum(L[:K])
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Solution (Python):

n, k = [int(s) for s in input().split()]
l = [int(s) for s 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())), reverse = True)

ans = 0

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

print(ans)

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

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

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

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

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

print(sum(ll[: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[n-k:n]))

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

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

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


if __name__ == "__main__":
    n, k = map(int, input().split())
    l = list(map(int, input().split()))

    main(n, k, l)

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

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

Solution (Python):
N,K=map(int,input().split())
li=list(map(int,input().split()))
li_sort=sorted(li,reverse=True)
print(sum(li_sort[: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())
llist = sorted(list(map(int, input().split())), reverse=True)
print(sum(llist[:K]))

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
a = inpl()
a.sort(reverse=True)
print(sum(a[:k]))

Solution (Python):
N,K = map(int,input().split())
L =[int(x) for x in input().split()]
L.sort()
result = 0
for i in range(1,K+1):
  result += L[-i]
print(result)

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

l = sorted(l, reverse=True)

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

print(answer)

Solution (Python):
N, K = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]
LL = sorted(L, reverse=True)
LL_max = sum([LL[i] for i in range(0, K)])
print(LL_max)

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

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

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

n, k = [int(x) for x in input().split()]
l = [int(l) for l in 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);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[:k]))

Solution (Python):

N,K = map(int, input().split())
l_list = [int(e) for e in input().split()]

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

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

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

l.sort()

ans = 0
for i in range(n-1, n-k-1, -1):
    ans += l[i]

print(ans)

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

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

n.sort(reverse=True)

x = 0

for i in range(b):
    x += n[i]

print(x)

Solution (Python):
n, k = map(int, input().split())
l = sorted(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())))[::-1]
s=0
for i in range(k):
  s += l[i]
print(s)

Solution (Python):
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(N, K, inputs):
    rods = string_to_int(inputs[0])
    rods.sort()
    length = 0
    for i in range(K):
        length += rods.pop()
    return length


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    [N, K] = string_to_int(input())
    ret = solve(N, K, inputs(1))
    print(ret)

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

l_list.sort(reverse=True)

total_length = 0
i = 0
while i < K:
    total_length += l_list[i]
    i += 1

print(total_length)

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

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

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

Solution (Python):

N, K, *l = map(int, open(0).read().split())

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

Solution (Python):
a = [list(map(int,input().split())) for l in range(2)]

N=a[0][0]
K=a[0][1]
L=a[1]

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

Solution (Python):
N,K = map(int,input().split())
x = list(map(int,input().split()))
x.sort(reverse=True)
print(sum(x[0: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 = map(int, input().split())

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

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

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

ans = 0

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

Solution (Python):
a,b=input().split()
A = input().split()
B = [int(s) for s in A]
a=int(a)
b=int(b)
for i in range(a-b):

    mi=min(B)
    B.remove(mi)
    B=list(B)
p=sum(B)

print(p)

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

print(total)

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

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

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

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

l.sort(reverse=True)
L=0
for i in range(K):
     L+=l[i]
print(L)

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):
N, K = map(int, input().split())
l = [int(l) for l in input().split()]

l = sorted(l, reverse=True)
snake = 0
for i in range(len(l)):
    if i >= K:
        break
    snake += l[i]

print(snake)

Solution (Python):

line1 = input()

splitLine1 = line1.split()



n = int(splitLine1[0])
k = int(splitLine1[1])


line2 = input()

splitLine2 = line2.split()


lengthList = []
for i in range(n):
  eachLengthNum = int(splitLine2[i])
  lengthList.append(eachLengthNum)


lengthList.sort()


lengthList.reverse()


resultLengthSum = 0
for i in range(k):
  resultLengthSum += lengthList[i]


print(resultLengthSum)

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

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

print(len)

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    l = list(map(int, input().rstrip('\n').split()))
    l.sort()
    print(sum(l[-k:]))


if __name__ == '__main__':
    slove()

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

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

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

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())

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

ans=0

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

print(ans)

Solution (Python):
N, K = list(map(int, input().split()))
nums = list(reversed(sorted(list(map(int, input().split())))))
print(sum(nums[: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[:k]))

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

Solution (Python):
a, b = map(int, input().split())
A = sorted(map(int, input().split()))
A.sort(reverse=True)
print(sum(A[0:b]))

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

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

Solution (Python):
class PriorityQueue:
    def __init__(self,priority):
        self.__queue=[]
        self.__priority=priority
    def __getvalue(self,i):
        return self.__queue[i-1]
    def __changevalue(self,node1,value1):
        self.__queue[node1-1]=value1
    def __swapvalue(self,node1,node2):
        t=self.__getvalue(node1)
        self.__changevalue(node1,self.__getvalue(node2))
        self.__changevalue(node2,t)
    def __cmp(self,node1,node2):
        return self.__priority(self.__getvalue(node1),self.__getvalue(node2))
    def __update_down(self,node):
        l=node<<1
        r=(node<<1)+1
        largest=node
        if l<=self.getlen() and self.__cmp(l,node)==True:
            largest=l
        if r<=self.getlen() and self.__cmp(r,largest)==True:
            largest=r
        if largest!=node:
            self.__swapvalue(node,largest)
            self.__update_down(largest)
    def __update_up(self,node):
        father=node>>1
        if father<1:
            return 
        if self.__cmp(node,father):
            self.__swapvalue(node,father)
            self.__update_up(father)
    
    
    def getlen(self):
        return len(self.__queue)
    def empty(self):
        if self.getlen()==0:
            return True
        else:
            return False
    def top(self):
        return self.__queue[0]
    def push(self,value):
        self.__queue.append(value)
        self.__update_up(self.getlen())
    def pop(self):
        self.__swapvalue(1,self.getlen())
        self.__queue.pop()
        self.__update_down(1)

class compare:
    greater=lambda x,y: x>y
    less=lambda x,y: x<y

n,k=input("").split()
n,k=int(n),int(k)
l=input("").split()
l=list(map(int,l))
pq=PriorityQueue(compare.greater)
for i in l:
    pq.push(i)
sum=0
while k>0:
    sum=sum+pq.top()
    pq.pop()
    k=k-1
print(sum)

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

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

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

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

Solution (Python):
N,M=map(int,input().split())
L=sorted(list(map(int,input().split())))[::-1]
n=0
for i in L[0:M]:
  n+=i
print(n)

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

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

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())
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,reverse=True)

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    l = list(map(int, input().rstrip('\n').split()))
    l.sort()
    print(sum(l[-k:]))


if __name__ == '__main__':
    slove()

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

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

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
N,K=map(int,input().split())
l=list(map(int,input().split()))
ls=sorted(l)

print(sum(ls[N-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 = [int(i) for i in input().split()]
l.sort(reverse=True)
print(sum(l[0:K]))

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

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 = 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()
ans = 0
for i in range(K):
    ans += l[len(l) - 1 - i]
print(ans)

Solution (Python):
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(K):
    ans += l[len(l) - 1 - 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_list = sorted(l_list, reverse=True)
print(sum(l_list[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[0:K]))

Solution (Python):
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
L = sorted([int(_) for _ in stdin.readline().rstrip().split()], reverse=True)
print(sum(L[: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 = map(int, input().split())
L = list(map(int, input().split()))
L.sort(reverse=True)
L = L[:K]
ans = sum(L)
print(ans)

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

Solution (Python):
N,K = map(int,input().split())
l = sorted(map(int,input().split()),reverse = True)
print(sum([i for i in l[0: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(map(int,input().split()),reverse=True)
print(sum(L[:K]))

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

ls = sorted(ls, 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())
L = [int(x) for x in input().split()]
L.sort(reverse=True)
print(sum(L[:K]))

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

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

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

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

sum = 0

for i in range(k):
    sum += bows.pop(bows.index(max(bows)))

print(sum)

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 = sorted(l)
lsum = sum(l)
ksum = 0
for i in range(n-k):
  ksum = ksum + l[i]
print(lsum - ksum)

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

Solution (Python):
import numpy as np
import sys
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())
ls = sorted(map(int, input().split()), reverse=True)
print(sum(ls[:k]))

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 = [int(i) for i in input().split()]
l.sort(reverse = True)
ans =0
for j in range(k):
  ans += l[j]
print(ans)

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

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

a.sort(reverse=True)

print(sum(a[:k]))

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


if __name__ == "__main__":
    resolve()

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

list.sort(l_list, reverse = True)
print(sum(l_list[: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()

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

Solution (Python):


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

l_sort = sorted(l, reverse=True)

print(sum(l_sort[:k]))

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

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

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

Solution (Python):
n,k = map(int,input().split())
l = list(map(int,input().split()))
ans = 0
for i in range(k):
    ans += max(l)
    l.remove(max(l))
    
print(ans)

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

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

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

print(ans)