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

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

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

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

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

rods.sort()
rods.reverse()

A=rods[:K]

print(sum(A))

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

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

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

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

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

print(sum([length[i] for i in range(k)]))

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

Solution (Python):
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

n, k = nm()
l = nl()

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

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

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

ans = 0
for i in range(K):
	m = max(l)
	ans += m
	l[l.index(m)] = 0
print(ans)

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

Solution (Python):
t,l=open(0);print(sum(sorted(map(int,l.split()))[-int(t[2:]):]))

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

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

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

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

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()) 
a = list(map(int, input().split()))
a.sort()
ans = 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()
l=l[::-1]
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):
import sys

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    L = list(map(int, input().split()))

    L = sorted(L, key=lambda x: -x)

    return sum(L[:K])


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

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

numbers.sort()
numbers.reverse()
result = sum(numbers[:K])

print(result)

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

hoge.sort(reverse=True)

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


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

l.sort()
ans = 0

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

print(ans)

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

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

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

Solution (Python):
n,k=map(int,input().split())
ls=list(map(int,input().split()))
length=0
for i in range(k):
  length+=max(ls)
  del ls[ls.index(max(ls))]
print(length)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


"""
a,b = LI()
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
    print("Possible")
else:
    print("Impossible")
"""

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

"""
n = I()
a = LI()
b = [None for i in range(n-1)]
for i in range(n-1):
    a[i+1] += a[i]
for i in range(n-1):
    b[i] = abs(2*a[i]-a[n-1])
print(min(b))
"""


"""
n = I()
v = [[] for i in range(n)]
for i in range(n-1):
    a,b = LI()
    a -= 1
    b -= 1
    v[a].append(b)
    v[b].append(a)
d_f = [-1 for i in range(n)]
q = deque()
q.append(0)
d_f[0] = 0
while q:
    x = q.pop()
    for y in v[x]:
        if d_f[y] == -1:
            d_f[y] = d_f[x] + 1
            q.append(y)
d_s = [-1 for i in range(n)]
q.append(n-1)
d_s[n-1] = 0
while q:
    x = q.pop()
    for y in v[x]:
        if d_s[y] == -1:
            d_s[y] = d_s[x] + 1
            q.append(y)
f = 0
s = 0
for i in range(n):
    if d_f[i] <= d_s[i]:
        f += 1
    else:
        s += 1
if f > s:
    print("Fennec")
else:
    print("Snuke")
"""

Solution (Python):
n, k = map(int, input().split())
l = list(reversed(sorted([int(i) for i in input().split()])))
print(sum(l[: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):
I=lambda:map(int,input().split())
_,K=I()
print(sum(sorted(I())[-K:]))

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

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

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

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

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

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

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

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


if __name__ == "__main__":
    N, K = map(int, input().split())
    l = [int(s) for s in input().split()]
    ans = snake_toy(N, K, l)
    print(ans)

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

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

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


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):
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=[int(j) for j 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()))[:-k-1:-1]))

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

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

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

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

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

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

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

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

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

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

ans = 0

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

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

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

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

Solution (Python):
N,K=map(int,input().split(' '))
print(sum(sorted(list(map(int,input().split(' '))))[::-1][: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()))
slide = N - K + 1
Max = sum(l[:K])
Sum = 0
count = 0
m = sorted(l)

for i in range(0,slide):
        Sum = sum(m[i:K+i])
        if Max < Sum:
                 Max = Sum
print(Max)

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+=a[i]
print(sum)

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

print(sum(a[:k]))

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

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

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

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

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

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

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
ans = sum(A[:K])
print(ans)

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

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

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

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

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

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

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

print(sum(l))

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

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

for i in range(N):
  l[i] = int(l[i])
l.sort()

for i in range(K):
  sum += l.pop(-1)
print(sum)

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

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

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

Solution (Python):

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

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

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

L.sort()

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

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

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

Solution (Python):

"""
Created on Sat Mar  2 02:34:54 2019

@author: yuta
"""

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

def main(n,k,l):
    l_sort = sorted(l,reverse = True)
    print(sum(l_sort[:k]))

main(N,K,L)

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

print(sum(l[:k]))

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

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

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("Heisei")
    else:print("TBD")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())



n,k= (int(i) for i in input().split())      


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







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

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

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

Solution (Python):


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

l.sort(reverse=True)

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

print(total)

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)
count = 0
length = 0
while count < k:
    length += l[count]
    count += 1
print(length)

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

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

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

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

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

Solution (Python):

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

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

a.sort(reverse=True)

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

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

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

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

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

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

Solution (Python):

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

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

Solution (Python):


n_k = list(map(int,input().split()))
li = list(map(int,input().split()))
n=n_k[0]
k=n_k[1]

toy = 0
li.sort(reverse=True)

for i in range(k):
    toy += li[0]
    li.pop(0)
print(toy)

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())
x=[int(i) for i in input().split()]
ans=0
for i in range(k):
    x.sort()
    ans+=max(x)
    x.pop(-1)
print(ans)

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
l = sorted(list(li()), 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)[::-1]
ans = 0
for i in range(K):
    ans = ans + L[i]
print(ans)

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

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

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

Solution (Python):
int_n, int_k = map(int, input().split())
ar_int_l = list(map(int, input().split()))

print(sum(sorted(ar_int_l, reverse=True)[:int_k]))

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

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

ls = sorted(l)[::-1]
ans = sum(ls[:X])
print(ans)

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

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

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

    l.sort(reverse=True)

    l2 = l[:k]
    print(sum(l2))


if __name__ == '__main__':
    main()

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

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

Solution (Python):
l1 = input().split()
N, K = map(int, l1)
max  = K+1
l2 = input().split()
l2 = list(map(int, l2))

l3 = sorted(l2)
sum = 0


for i in range(1, max) :
    sum += l3[-i]

print(sum)

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

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

L.sort(reverse=True)

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

print(ans)

Solution (Python):


import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, k = LI()
L = LI()

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

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

length = sum(l_sort[:K:])
print(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())
str_l = input().split()
l = [int(i) for i in str_l]

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

Solution (Python):

def getIntList(): return [int(x) for x in input().split()]
def db(x): 
    global debug
    if debug: print(x)
debug = False
N,K = getIntList()
L = getIntList()
db((N,K))
db(L)
L.sort()
L.reverse()
db(L)
print(sum(L[:K]))

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

Solution (Python):
s=input().split();n=int(s[0]);k=int(s[1]);s=input().split();m=[];ans=0
for i in s:
    m.append(int(i))
m=sorted(m);m.reverse()
for j in range(0,k):
    ans+=m[j]
print(ans)

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

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

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

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

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

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

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

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

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

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

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

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

A = sum(ans)
print(A)

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

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

Solution (Python):
n, k = map(int, input().split())
print(sum([list(reversed(sorted(list(map(int, a.split())))))[i] for a in [input()] for i in range(k)]))

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

Solution (Python):
import sys

input = sys.stdin.readline


def ii():
    return int(input())


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


N, K = il()
L = il()
print(sum(sorted(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())
Li = list(map(int, input().split()))
Li.sort(reverse=True)

length = 0
for i, l in enumerate(Li):
  length += l
  if i == k - 1:
    break
    
print(length)

Solution (Python):


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

L = sorted(L,reverse=True)

Sum_l = sum(L[0:K])
print(Sum_l)

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