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 = sum(l[:k])
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):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

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

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

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

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

Solution (Python):




"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""








def main():
  n,k = map(int,input().split())
  l = list(map(int,input().split()))
  
  l = sorted(l,reverse=True)
  
  print(sum(l[:k]))
  
if __name__ == '__main__':
  main()

Solution (Python):
n,k=list(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.sort(reverse=True)
ans=sum(l[:K])

print(ans)

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

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

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

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

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

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

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

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

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

l.sort(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()]

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

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
ans = 0
n,k = iim()
L = sorted(iil(),reverse=True)
for i in range(k):
    ans += L[i]

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

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

print(sum(l_list[:k]))

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

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

t.sort(reverse=True)

ans = 0

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

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

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

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

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

print(ans)

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

for i in range(k):
  ans+=sorted(ls)[-a]
  a+=1
  
print(ans)

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

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

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

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

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

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

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())
a=sorted(list(map(int,input().split())), reverse=True)
print(sum(a[: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):
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
l = na()

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

GBN_DEBUG = False
GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)






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

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

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

Solution (Python):



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


l_list = sorted(l_list, reverse=True)
max_len = sum(l_list[:K])


print(max_len)

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

Solution (Python):

import sys
input = sys.stdin.readline

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

Solution (Python):

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

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, k = MAP()
l = LIST()
l.sort(reverse=True)
print(sum(l[:k]))

Solution (Python):












mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

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

if __name__=='__main__':
    main()

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

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

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

print(sum(l[:k]))

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

Solution (Python):



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


max_cost = 0
l_list = sorted(l_list, reverse=True)


max_cost = sum(l_list[:K])
print(max_cost)

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

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

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
l = na()
l = sorted(l)

print(sum(l[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):

GBN_DEBUG = False
GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)






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

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

l.sort(reverse=1)
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)
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())))
a = 0
for i in range(k):
    a += l[-(i+1)]
print(a)

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

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

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):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, k = MAP()
l = LIST()
l.sort(reverse=True)
print(sum(l[:k]))

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

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

snake = 0
lst.sort(reverse=True)

for num in range(0, k):
    snake += lst[num]

print(snake)

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

l = list(map(int,input().split()))
s = 0
for i in range(K):
    a = max(l)
    s += a
    l.remove(a)

print(s)

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

Solution (Python):
N, K = map(int, input().split())
print(sum(sorted(list(map(int, input().split())))[N-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())
length = list(map(int, input().split()))
max_length = 0

length.sort(reverse=True)
for i in range(K):
  max_length += length[i]
  
print(max_length)

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()))
sort_a = sorted(l, reverse=True)
sum = 0

for i in range(K):
    sum += sort_a[i]

print(sum)

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

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

stics = sorted(stics, reverse=True)

print(sum(stics[:K]))

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

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

Solution (Python):
import sys

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

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









l.sort(reverse=True)

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

print("{}".format(max_length))

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

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

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

for i in range(k):
    s += l[i]
    
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):

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

import sys
try:
    from typing import List
except ImportError:
    pass


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


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

Solution (Python):








def resolve():

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

    print(sum([L[i] for i in range(K)]))


resolve()

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

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

list.sort()
list.reverse()

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

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

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

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

sum = sum(l)
for i in range(N-K):
    sum-=l[i]
print(sum)

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

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

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

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

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

Solution (Python):
N,K=map(int,input().split())
l=input().split()
numbers=[int(a) for a in l]
answers=sorted(numbers,reverse=True)
list=[]
for b in range(K):
    list.append(answers[b])
print(sum(list))

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

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

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

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

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)
a=sum(l[:k])
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 = sorted(map(int, input().split()), reverse=False)
A = sorted(map(int, input().split()), reverse = True)
sum=0
for i in range(0,N[0]):
         sum=sum+int(A[i])
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 = input()
n = n.split(" ")
n = list(map(int, n))
len_ = n[1]

length = input()
length = length.split(" ")
length = list(map(int, length))
length.sort()


length.reverse()
len_max = length[0 : len_]
max_ = sum(len_max)

print(max_)

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

total = 0

for i in range(k):
    total += sticks[i]

print(total)

Solution (Python):
k = int(input().split()[1])
sticks = sorted(list(map(int,input().split())),reverse=True)

total = 0

for i in range(k):
    total += sticks[i]

print(total)

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)



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()))[-K:]))

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

Solution (Python):
def main():
    import sys
    
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    
    from itertools import combinations, permutations
    
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    

    

    n,k =map(int, input().split())
    l = list(map(int, input().split()))
    l = sorted(l, reverse=1)
    res = 0
    for i in range(k):
        res += l[i]
    print(res)
if __name__ == '__main__':
    main()

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(map(int,input().split()))
l=sorted(l)
total=0
t_ans=0
for i in range(N):
    total+=l[i]
for i in  range(N-K):
    t_ans+=l[i]
print(total-t_ans)

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

total = 0
for k in range(K):
  total += L[k]
  
print(total)

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)
res = 0
for i in range (k):
    res += l[i]
print(res)

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

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

Solution (Python):

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    l=LI()
    l.sort(reverse=True)
    ans=sum(l[:K])
    print(ans)

main()

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

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

Solution (Python):
I = list(map(int, input().split()))
N, K = I[0], I[1]

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

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

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

print(sum(l[:k]))

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

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

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

dct = sorted(L, reverse=True)

ans = []

for i in range(K):
    ans.append(dct[i])

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

Solution (Python):
n, k = [int(e) for e in input().split()]
sticks_length = list(map(int, input().split()))
sticks_length.sort(reverse=True)
print(sum(sticks_length[:k:1]))

Solution (Python):
N,K=map(int,input().split())
L=list(map(int,input().split()))
stick=[0]*K
for l in L:
    minimum=min(stick)
    if l>minimum:
        stick.remove(minimum)
        stick.append(l)
print(sum(stick))

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

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=[int(_) for _ in input().split()]
print(sum(sorted(l, reverse=True)[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()))

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

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())
A = list(map(int, input().split()))
A.sort()
m = 0

for i in range(1,K+1):
    m = m + A[-i]
    
print(m)