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

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

Solution (Python):
def main():
    sticks, join_num = map(int, input().split())
    length = list(map(int, input().split()))
    length.sort(reverse=True)
    print(sum(length[:join_num]))


if __name__ == '__main__':
    main()

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

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

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

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

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

lists.sort(reverse=True)

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

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

A.sort()
A.reverse()

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

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

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

A = sorted(A)

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

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

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

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

Solution (Python):



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

l_list.sort(reverse=True)

sum=0
for i in range(k):
    sum += l_list[i]

print(sum)

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

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

print(ans)

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

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

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

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

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

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

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

if __name__ == '__main__':
    main()

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

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

Solution (Python):
[N, K] = list(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(i) for i in input().split(" ")]
lst = [int(i) for i in input().split(" ") ]

lst.sort(reverse = True)

print(sum(lst[:K]))

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

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

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

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

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

l_new = sorted(l, reverse = True)

for i in range(0, K):
	sum += l_new[i]

print(str(sum))

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

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

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

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

Solution (Python):
def snaketoy(n , k , l):

    ans = 0
    l.sort(reverse=True)
    ans = int(sum(l[:k]))

    return ans

def main():
    n , k = map(int , input().split())
    l = list(map(int , input().split()))
    print(snaketoy(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)
r = sum(l[:k])
print(r)

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

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

Solution (Python):
try:
    N, K = map(int, input().split())
    _ = list(map(int, input().split()))
    __ = sorted(_, reverse = True)
    print(sum(__[0:K]))
except EOFError:
    pass

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

print(ans)

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

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

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

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

Solution (Python):




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

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

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

l = sorted(l, key= lambda x: -x)
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):
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):
import sys, bisect, math, itertools, string, queue, copy


from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,k = inpm()
    l = inpl()
    l.sort()
    l.reverse()
    ans = 0
    for i in range(k):
        ans += l[i]
    print(ans)
    
if __name__ == "__main__":
    main()

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

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

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):
kazu, pick = map(int, input().split())
nagasalist = list(map(int, input().split()))
dst = sum(sorted(nagasalist)[-pick:])
print(dst)

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

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

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

a_list = sorted(a_list, reverse=True)

ans = 0

for i in range(k):
	ans = ans + a_list[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 = map(int, input().split())

LL = sorted(L, reverse=True)

sm = 0
for i in range(k):
    sm += LL[i]
print(sm)

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

Solution (Python):
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools



read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

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

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

l.sort()

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

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

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

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

for i in range(len(la)-k, len(la)):
    ans += la[i]

print(ans)

Solution (Python):
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

N, K = getInput();
a_i = getInput()

a_i.sort(reverse=True)
sums = 0

for i in range(K):
    sums += a_i.pop(0)
print(sums)

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

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,k=INTM()
    L=LIST()
    L=sorted(L, reverse=True)
    print(sum(L[0:k]))
if __name__ == '__main__':
    do()

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

ans = sum(L[:K])

print(ans)

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

Solution (Python):







def intinput():
    return int(input())

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

def splitintinput():
    return map(int,input().split())
N,K= splitintinput()
l = listintinput()

l.sort(reverse=True)
ans = 0
for i in range(K):
    ans += l.pop(0)

print(ans)

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

print(sum)

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

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

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

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

print(ans)

Solution (Python):
n, k = map(int, input().split())
a = list(map(int, input().split()))
print(sum(sorted(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 permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
l = LIST()

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

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

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

print(sum(l[:k]))

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

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

print(ans)

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

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

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

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

if len(lens) <= K:
    print(sum(lens))
else:
    print(sum(lens[:K]))

Solution (Python):
import sys
input = sys.stdin.readline
N,K = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()
l.reverse()
sum = 0
for i in range(K) :
    sum+=l[i]
print(sum)

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

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

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

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

length = 0
for i in range(k):
  length += sList[i]

print(length)

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

Solution (Python):
N, K = map(int, input().split())
ls = sorted([int(i) for i in input().split()])[::-1]

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[i] for i in range(k)]))

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

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





L_desc = []
while len(L) > 0:
  maxVal = 0
  for i in range(len(L)):
    if L[i] > maxVal:
      maxVal = L[i]
  L_desc.append(maxVal)
  L.remove(maxVal)

snakeLength = 0
for l in range(K):
  snakeLength += L_desc[l]

print(snakeLength)

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

sorted_l = sorted(l, reverse=True)

max_len = 0
for i in range(K):
    max_len += sorted_l[i]

print(max_len)

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

L_desc = sorted(L, reverse=True)

snakeLength = 0
for l in range(K):
  snakeLength += L_desc[l]

print(snakeLength)

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

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

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

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

print(result)

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

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

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

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

print(sum(l[:K]))

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

max = 0

newLi = sorted(li, reverse=True)

for i in range(y):
  max += newLi.pop(0)

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):
import sys
input = sys.stdin.readline

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

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

print(ans)

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

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

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

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

res = 0

for _ in range(k):
    res += l.pop(l.index(max(l)))
print(res)

Solution (Python):
import sys


def solve(inp):
    (N, K) = map(int, inp.readline().split(' '))
    L = list(reversed(sorted(map(int, inp.readline().split(' ')))))

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

    return str(r)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

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

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

Solution (Python):


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

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

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

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

print(sum(l[:m]))

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

sl=sorted(l)
print(sum(sl[-k:]))

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

print(ans)

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    N, K = [int(item) for item in stdin.readline().split()]
    li = [int(item) for item in stdin.readline().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()
l.reverse()
ans=0
for i in range(k):
    ans+=l[i]
print(ans)

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

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

Solution (Python):

 
import math
import itertools
import sys
import copy
 

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



L.sort(reverse=True)

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

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

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

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

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

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

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

Solution (Python):
a = input().split()
ss = list(input().split())
s = []
for i in ss:
    s.append(int(i))
k = 0
for i in range(int(a[1])):
    d = max(s)
    k += d
    s.remove(d)
print(k)

Solution (Python):
import sys

n, k, *l = map(int, sys.stdin.read().split())

def main():
    l.sort(reverse=True)
    return sum(l[:k])

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

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[i] for i in range(K)]))

Solution (Python):
n,k,*l=map(int,open(0).read().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()]
print(sum(sorted(l, reverse=True)[: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[n-i-1]
print(ans)

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

Solution (Python):
import sys

n,k = map(int, sys.stdin.readline().split())

l = list(map(int, sys.stdin.readline().split()))

l.sort()

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

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

ll = sorted(ll)

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

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

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

print(sum(snakes[:K]))

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

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

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

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

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

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

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

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

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

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

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

buf=sorted(l,reverse=True)
result=0

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

print(result)

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 = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]
print(sum(sorted(L)[N - K:]))

Solution (Python):
n, k = list(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())
A = list(map(int, input().split()))

A.sort(reverse=True)

AMAX = A[0:K]

print(sum(AMAX))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,k=MI()
    ll=LI()
    ll.sort(reverse=True)
    print(sum(ll[:k]))
    
main()

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

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

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

Solution (Python):
n,k=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
ans=0
for i in range(k):
    ans+=l.pop(l.index(max(l)))
print(ans)

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

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

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

Solution (Python):





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

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

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



def main()->None:
    (N, K) = map(int, input().split())
    l = list(map(int, input().split()))

    sorted_l = sorted(l, reverse=True)
    s = 0
    for i in sorted_l[:K]:
        s += i

    print(s)


if __name__ == "__main__":
    main()

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

print(sum(newList[:k]))

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

ls_sorted = list(reversed(sorted(ls_l)))

print(sum(ls_sorted[:k]))

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

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