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 = sorted(l, reverse=True)
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):
a, b = map(int, input().split())
final = list(map(int, input().split()))

final.sort(reverse = True)
print(sum(final[:b]))

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

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

Solution (Python):
from typing import List


def answer(n: int, k: int, l: List[int]) -> int:
    l.sort(reverse=True)
    return sum(l[:k])


def main():
    n, k = map(int, input().split())
    l = list(map(int, input().split()))
    print(answer(n, k, l))


if __name__ == '__main__':
    main()

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

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

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

print(sum_length)

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

def main():
    _, k = map(int, input().split())
    l = list(map(int, input().split()))
    cnt = 0
    l.sort(reverse=True)

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



if __name__ ==  "__main__":
    main()

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

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

for i in range(K):
    Sum += l[N - i - 1]

print(Sum)

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

l = sorted(l, reverse=True)
cn = 0
for i in range(K):
    cn = cn + l[i]
    
print(cn)

Solution (Python):
lst = input().split()
N = int(lst[0])
K = int(lst[1])

L = input().split()
for i in range(N):
   L[i] = int(L[i])

L.sort(reverse=True)

ans = 0

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

print(ans)

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

lst = sorted(lst)
print(sum(lst[(-1) * k:]))

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

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

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=[int(x) for x in 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):
import sys
from typing import List

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

bar = sorted(ll)[::-1]

ans = sum(bar[0:k])

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

print(ans)

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

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

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

Solution (Python):
n, k = (int(x) for x in input().split())
L = [int(x) for x in input().split()]
ans = sum(sorted(L, reverse=True)[:k])
print(ans)

Solution (Python):
with open(0) as f:
    N, K, *l = map(int, f.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.sort(reverse=True)

print(sum(L[:K]))

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

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

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

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

l.sort(reverse=True)
snake = []

for i in range(K):
    snake.append(l[i])

print(sum(snake))

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

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

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

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

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

print(sum(l[:K]))

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

print(sum(L[:K]))

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

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

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, K = map(int, readline().split())
    l = list(map(int, readline().split()))

    l.sort(reverse=True)

    print(sum(l[:K]))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
n,k = map(int, sys.stdin.readline().rstrip("\n").split())
l = [int(s) for s in sys.stdin.readline().rstrip("\n").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 = list(map(int, input().split()))

l_sorted = sorted(l, reverse=True)
total = 0
for i in range(K):
    total += l_sorted[i]

print(total)

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

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

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

print(sum(L)-s)

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


print(sum(l[:K]))

Solution (Python):



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


if __name__ == "__main__":
    main()

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

Solution (Python):

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

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

sum = 0
cnt = 0
while K > cnt:
    sum += l[cnt]
    cnt += 1
print(sum)

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

abc067b_snake_toy()

Solution (Python):


num, choose_num = map(int, input().split())
total = 0
stick_length = input().split(" ")

str_num = [int(n) for n in stick_length]
list.sort(str_num, reverse=True)

for i in range(choose_num):
    total += str_num[i]

print(total)

Solution (Python):
N_hon, K_part = map(int, input().split())
length = list(map(int, input().split()))

length.sort()
ans = sum(length[-K_part:])

print(ans)

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

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



def main():
    N, K, *L = map(int, open(0).read().split())
    L.sort()
    print(sum(L[-K:]))


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

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

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

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

print(sum(sorted(num_list, reverse=True)[: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):
a,b=input().split()
a=int(a)
b=int(b)
c=list(map(int,input().split()))
c.sort()
d=0
for i in range(b):
  d=d+c[-i-1]
print(d)

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

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

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

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

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

Solution (Python):
n, k = 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(reverse = True)
sum = 0
for i in range(k):
    sum = sum + a[i]
print(sum)

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

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

s = sorted(l)

ans = sum(s[N - K:])

print(ans)

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

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

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

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

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

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

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

Solution (Python):
a,b=map(int,input().split())
le=list(map(int,input().split()))
le.sort()
gou=0
for i in range(b):
  gou+=le.pop()
print(gou)

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

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

Solution (Python):
N,K = map(int,input().rstrip().split(" "))
I = list(map(int,input().rstrip().split(" ")))
I.sort(reverse = True)
ans = 0
for i in range(K):
    ans += I[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 = 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 = list(map(int, input().split()))

l_sorted = sorted(l, reverse = True)
snake = 0
for i in range(k):
    snake += l_sorted[i]
print(snake)

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

print(sum(i[-b:]))

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

L.sort() 
L_len = len(L) 
print(sum(L[-k:]))

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

length = sum(l[0 : k])

print(length)

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, k = i_map()
    num_list = i_list()

    num_list.sort(reverse=True)

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

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

Solution (Python):



import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5 3
1 2 3 4 5"""
        output = """12"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """15 14
50 26 27 21 41 7 42 35 7 5 5 36 39 1 45"""
        output = """386"""
        self.assertIO(input, output)


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


if __name__ == "__main__":
    
    resolve()

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

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

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

	l.sort(reverse = True)

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

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

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

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, k = rm()
li = sorted(rl(), reverse=True)
print(sum(li[:k]))

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

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n, k = M()
l = LI()
l.sort(reverse=True)
ans = 0
for i in range(k):
    ans += l[i]
print(ans)

Solution (Python):
n,k = map(int, raw_input().split())
ais = map(int, raw_input().split())
ais.sort()
print sum(ais[-k:] or [0])

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[-i-1]
print(ans)

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

rev_sorted_A = list(reversed(sorted(A)))
print(sum(rev_sorted_A[:K]))

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    L = list(map(int, readline().split()))
    L.sort(reverse=True)
    ans = 0
    for l in L[:K]:
        ans += l
    print(ans)


if __name__ == '__main__':
    main()

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

print(sum(l[:K]))

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

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

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

Solution (Python):

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

an = []
for i in range(K):
    an.append(max(ln))
    del ln[ln.index(max(ln))]

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

print(str(k))

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

Solution (Python):
import heapq
N, K = map(int, input().split())
L = list(map(int, input().split()))
print(sum(heapq.nlargest(K,L)))

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

print(sm)

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[-i-1]
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


def main():
    n, k = map(int, input().split())
    L = list(map(int, input().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())))
l.reverse()
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())))

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

Solution (Python):
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
  N, K = map(int, input().split())
  L = list(map(int, input().split()))
  L.sort(reverse=True)
  ans = sum(L[:K])
  return ans
print(solve())

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

Solution (Python):

















import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
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
import numpy as np
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 = sorted(list(MAP()), reverse=True)

print(sum(l[:K]))

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

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

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


if __name__ == '__main__':
    main()

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

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

print(length)

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

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

ls = sorted(l,reverse = 1)

print(sum(ls[: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 = input().split()
N = int(N)
K = int(K)

l = input().split()

l_i = []
for s in l:
    l_i.append(int(s))
    
l_i.sort(reverse = True)

l_s = l_i[:K]

print(sum(l_s))

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

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

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *L = map(int, read().split())

    L.sort(reverse=True)

    print(sum(L[:K]))

    return


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

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

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

print(sum(l[: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):
a,b=map(int,input().split())
List = list(map(int, input().split()))
List.sort(reverse = True)
res = 0
for i in range(b):
  res += List[i]
print(res)

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

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

l.sort()

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

length.sort(reverse=True)
total = 0
for i in range(k):
  total += length[i]

print(total)

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[0: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[0:k]))

Solution (Python):
MM = input().split()
N = int(MM[0])
K = int(MM[1])
LL = input().split()
list1 =[]
for i in LL:
  a = int(i)
  list1.append(a)
list1.sort(reverse = True)

total = 0
for i in range(K):
  total += list1[i]
print(total)

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

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

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

Solution (Python):
def actual(N, K, L):
    return sum(sorted(L)[-K:])

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

print(actual(N, K, L))

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

Solution (Python):
s = input().split()

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

snakes = []

p = input().split()
for i in range(n):
    q = int(p[i])
    snakes.append(q)

snakes.sort()

answer = 0

for i in range(k):
    x = snakes.pop()
    answer += x

print(answer)

Solution (Python):
n,k = map(int,input().split())
line = list(map(int,input().split()))
line.sort(key=int)
count = -1
output = 0
for _ in range(k):
    output += line[count]
    count += -1
print(output)

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

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):
_, k = map(int, input().split())
l = [int(x) for x in input().split()]
l.sort()
print(sum(l[-k:]))

Solution (Python):
def main():
    n,k=map(int, input().split())
    A=[int(i) for i in input().split()]
    A.sort(reverse = True)

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

if __name__ == '__main__':
    main()

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()
a=0
for i in range(N-K,N):
  a+=l[i]
print(a)