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

lines = sys.stdin.readlines()

for n, line in enumerate(lines):
  if n == 0:
    n, k = [int(_) for _ in line.strip().split(' ')]
  elif n == 1:
    bars = [int(_) for _ in line.strip().split(' ')]
  else:
    raise

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

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

l1 = input().split()
l = []
for j in l1:
    l.append(int(j))

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

print(ans)

Solution (Python):



import time
from contextlib import contextmanager

@contextmanager
def timer(title):
	t0 = time.time()
	yield
	print("{} - done in {:.0f}s".format(title,time.time()-t0) )

def  calcLongSnakeToy(needBarNumber,barLengthList):
	longSortedToyList = sorted(barLengthList,reverse=True)
	getBarCountRange = range(0,needBarNumber,+1)
	longLength = 0
	for i in getBarCountRange:
		longLength = longLength + longSortedToyList[i]
	answer = longLength
	return answer


if __name__ == '__main__':
	_,K = map(int,input().strip().split(' '))
	lengthList = list(map(int,input().strip().split(' ')))
	solution=calcLongSnakeToy(K,lengthList)
	print("{}".format(solution))

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

l.sort(reverse=True)

ans = sum(l[:K])
print(ans)

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


abc067_b()

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

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

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

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

print(sum(l[:K]))

Solution (Python):

import numpy as np
a , b = map(int,input().split())
c = list(map(int,input().split()))
c.sort()
c = c[::-1]
d = np.array(c)
print(d[0:b].sum())

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

Solution (Python):



def main():
    """Function."""
    n, k = map(int, input().split())
    line = list(map(int, input().split()))
    line.sort()

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


if __name__ == "__main__":
    main()

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

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


if __name__ == '__main__':
    main()

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

xs = sorted(L)
result = sum(xs[-K:])

print(result)

Solution (Python):
N, K = map(int, input().split(' '))
bars = [int(length) for length in input().split(' ')]
bars.sort(reverse=True)

sum_len = 0

for i in range(K):
    sum_len += bars[i]

print(sum_len)

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

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

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

print(sum)

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

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

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

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

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

nums.sort(reverse=True)

for i in range(k):
  ans += nums.pop(0)
  
print(ans)

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

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

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

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

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

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

a=input().strip().split(" ")

a=[int(i) for i in a]

a.sort()
a.reverse()

Sum=0

for i in range(K):
    Sum+=a[i]

print(Sum)

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

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

print(result)

Solution (Python):

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

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

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

print(sum(l[:k]))

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

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

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

Solution (Python):
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = sorted(b)
d = c[:(a[0]-a[1])]

print(sum(c)-sum(d))

Solution (Python):

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


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


A = sorted(A, reverse = True)



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

print(ans)

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

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

print(ans)

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

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

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

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

Solution (Python):
N, K = list(map(int, input().strip().split(' ')))
array = list(map(int, input().strip().split(' ')))
num = sorted(array, reverse=True)
num1 = num[:K]
ans = sum(num1)
print(ans)

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

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

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

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

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

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

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

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(_) for _ in input().split()]

l.sort(reverse=True)

print(sum(l[:k]))

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

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

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

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

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

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

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

Solution (Python):
from sys import stdin


def main() -> int:
    n, k = map(int, input().split())
    l = [next_int() for _ in range(n)]
    l.sort()
    l.reverse()

    ans = sum(l[:k])
    print(ans)
    return 0


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


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

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

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

Solution (Python):
N,K = map(int, input().split())
l = [int(_) for _ 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.sort(reverse=True)

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

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

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

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

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

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

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

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

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

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

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

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

index=0
sum=0
while index<k:
    sum+=listL[index]
    index+=1
print(sum)

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

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

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

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

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

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

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

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

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

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return




dp = None


def main():
    N, K = li_input()
    L = li_input()

    L.sort(reverse=True)

    print(sum(L[:K]))


main()

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

res = 0
for i in range(K):
	temp = max(l)
	l.remove(temp)
	res += temp
    
print(res)

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

Solution (Python):
num,length = map(int,input().split())
lis = [int(m) for m in input().split()]
total = 0
for i in range(length):
    total += max(lis)
    lis.remove(max(lis))
print(total)

Solution (Python):

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

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):
def solve():
    n, k = map(int, input().split())
    lists = list(map(int, input().split()))
    lists = sorted(lists, reverse=True)
    result = 0
    for i in range(k):
        result += lists[i]
    print(result)


solve()

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

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

Solution (Python):

n, k = map(int, raw_input().split())
l = sorted(map(int, raw_input().split()), reverse=True)

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

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

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

Solution (Python):


def main():
    n, k = map(int, input().split())
    l_list = list(map(int, input().split()))
    l_list.sort(reverse=True)

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

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

N,K = inpl()
ll = inpl()
ll.sort(reverse=True)
print(sum(ll[:K]))

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

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

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

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

print(sum(b[:K]))

Solution (Python):










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










c=0
ans=0
for i in l:
  c+=1
  ans+=i
  if c >= k:
    break

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()))
L.sort()
L.reverse()
print(sum(L[:K]))

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

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

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

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

print(res)

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

print(s)

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

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

a.sort()
a.reverse()

print(sum(a[0:m]))

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

print(sum(length_list[: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):
"""
https://abc067.contest.atcoder.jp/tasks/abc067_b
"""
[n,k]=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
l.sort()
a=0
for i in range(k):
    a=a+l[n-i-1]
print(a)

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

L_li.sort(reverse = True)

cnt = 0
ans = 0
for i in L_li:
        ans += i
        cnt += 1
        if cnt == K:
            break
            
print(ans)

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

Solution (Python):


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


num_list.sort(reverse=True)

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

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

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

result = 0

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

print(result)

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


stick=input().split()



for i in range(len(stick)):
	stick[i]=int(stick[i])




stick=sorted(stick,reverse= True)



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

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

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

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

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

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


print(sum(waw[0:M]))

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

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

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

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

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

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

res = 0
for i in range(K):
    res += sticks[i]
print(res)

Solution (Python):
lis = input().split(' ')
N= int(lis[0])
L = int(lis[1])

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


ans = 0
n = N - 1
for i in range(L):

    ans += l[n]
    n -= 1

print(ans)

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

length.sort(reverse=True)
snake_length = 0

for i in range(K):
    snake_length += length[i]

print(snake_length)

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

l.sort(reverse=True)

print('{}'.format(sum(l[:k])))

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

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

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


total = 0

for i in range(K):
    total = total + max(l)
    l.remove(max(l))

print(total)

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

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

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

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

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

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

print(l)

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