Problem:
 Score : 200 points    Problem Statement Snuke has N sticks.
The length of the i -th stick is l_i .  Snuke is making a snake toy by joining K of the sticks together.  The length of the toy is represented by the sum of the individual sticks that compose it.
Find the maximum possible length of the toy.      Constraints  1 \leq K \leq N \leq 50  1 \leq l_i \leq 50  l_i is an integer.         Input Input is given from Standard Input in the following format:  N  K  l_1  l_2  l_3  ...  l_{N}       Output Print the answer.        Sample Input 1 5 3
1 2 3 4 5      Sample Output 1 12  You can make a toy of length 12 by joining the sticks of lengths 3 , 4 and 5 , which is the maximum possible length.       Sample Input 2 15 14
50 26 27 21 41 7 42 35 7 5 5 36 39 1 45      Sample Output 2 386

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

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

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

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

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

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

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

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

l = sorted(l)

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

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

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

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

l_sorted = sorted(l_list, reverse=True)
l_sum = 0
for i in range(k):
    l_sum += l_sorted[i]

print(l_sum)

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

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

li.sort(reverse=True)

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

Solution (Python):



def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, typ=int):
    return [typ(input()) for _ in range(n)]

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


if __name__ == '__main__':
    main()

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

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

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

suml=0
for i in range(k):
    suml=suml+ll[i]
print(suml)

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

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

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

Solution (Python):
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()
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(reverse = True)
l = l[:K]
print(sum(l))

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

l_k=l[:k]

print(sum(l_k))

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

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

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


main()

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

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

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

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

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

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

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

snake = []
for i in range(K):
  value = max(l_list)
  l_list.remove(value)
  snake.append(value)

print(sum(snake))

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

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

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

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

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

for i in range(int(K)):
	length += int(Int[i])
print(length)

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)
result=[]
for i in range(K):
  result.append(l[i])

print(sum(result))

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

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

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

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.remove(m)
print(ans)

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

ls.sort()
print(sum(ls[-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]
else:
    print(ans)

Solution (Python):


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

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




if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data)
print(sum(data[-K:]))

Solution (Python):




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

new_list_reverse = sorted(org_list, reverse=True)

print(sum(new_list_reverse[:k]))

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

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, K = nl()
L = sorted(nl(), reverse=True)

print(sum(L[:K]))

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

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

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

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


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


if __name__ == "__main__":
    main()

Solution (Python):
n, k = map(int, input().split())
dat_l = list(map(int, input().split()))
dat_l.sort()
dat_l = dat_l[::-1]
print(sum(dat_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 solve(N: int, K: int, l: "List[int]"):
    l.sort(reverse=True)
    ret = sum(l[:K])
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    l = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, K, l)

if __name__ == '__main__':
    main()

Solution (Python):



N, K = map(int, input().split())
num_list = [int(i) for i in input().split()]
rev_list = sorted(num_list, reverse = True)
total = 0

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

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


abc()

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

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


N, K = list(map(int, sys.stdin.readline().split()))
L = list(map(int, sys.stdin.readline().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[n-1-i]
print(ans)

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

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):
input1 = input().split(" ")

N = int(input1[0])
K = int(input1[1])

list = input().split(" ")
num_list = []

for num in list:
    num_list.append(int(num))

num_list.sort(reverse=True)

length = 0
for k in range(K):
    length += num_list[k]
    
print(length)

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

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

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

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

Solution (Python):
nk = input().split(" ");
n = int(nk[0]);
k = int(nk[1]);
l = input().split(" ");
for i in range(n) :
	l[i] = int(l[i]);
l.sort()
ans = 0;
for i in range(k) :
	ans = ans + int(l[n-1-i]);
print(ans)

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

nums=sorted(nums,reverse=True)


print(sum(nums[:k]))

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

Solution (Python):

N, K = map(int, raw_input().split())
l_arr = map(int, raw_input().split())

l_arr_sorted = sorted(l_arr, reverse=True)
max_len = 0
for idx in range(0, K):
  max_len += l_arr_sorted[idx]

print(max_len)

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

def main():
    comb = []
    for l in L:
        if len(comb) < K:        
            comb.append(l)
        elif l > min(comb):
            comb[comb.index(min(comb))] = l
    print(sum(comb))

if __name__ == '__main__':
    main()

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

Solution (Python):


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

l.sort(reverse=True)

l = l[:k]

print(sum(l))

Solution (Python):
n,k = map(int,input().split())
A = [int(x) for x in input().split()]
A.sort()

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

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

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

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

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

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

Solution (Python):
nk = list(map(int,input().split(' ')))
nagasa = list(map(int,input().split(' ')))

nagasa.sort(reverse=True)

print((sum(nagasa[:nk[1]])))

Solution (Python):
n, k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
l.reverse()
i = 0
num = 0
while i < k:
  num += l[i]
  i += 1
print(num)

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

print(sum(L[:K]))

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

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

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

Solution (Python):
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=[]
for i in range(k):
    a=max(l)
    ans.append(a)
    l.remove(a)
print(sum(ans))

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

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

print(A)

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):
a,b = map(int, input().split())
c = map(int,input().split())
sList = sorted(c,reverse = True)
sum = 0

for i in range(b):
	sum = sum + sList[i]
print(sum)

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

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

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

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

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

Solution (Python):
from functools import reduce


n, k = map(lambda x: int(x), input().split(' '))
l = list(map(lambda x: int(x), input().split(' ')))

def add_num(a, b):
    return int(a) + int(b)

k *= -1
l.sort()
print(reduce(add_num, l[k:]))

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

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

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

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

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

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

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

print(ans)

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

sort_l = sorted(l, reverse=True)

cnt = 0
sum = 0
while cnt < K:
    sum += sort_l[cnt]
    cnt += 1
print(sum)

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

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

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

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

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

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

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

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

Solution (Python):


def solve():
    N, K = list(map(int, input().split()))
    L = list(map(int, input().split()))
    L.sort(reverse=True)

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

if __name__ == "__main__":
    solve()

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

print(sum(i[: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 = map(int,input().split())

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

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

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

l.sort()
l.reverse()


print(sum(l[:K]))

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

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

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

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

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

Solution (Python):
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]

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

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

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

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

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

print(sum(L[:K]))

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

Solution (Python):


import itertools
from collections import Counter
from collections import defaultdict
import bisect

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

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

print(sum(l[:b]))

Solution (Python):

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

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

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

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

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

print(ans)

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

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

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

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

ln = sorted(ln, key=lambda x:-x)
print(sum(ln[:k]))

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

Solution (Python):

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

Solution (Python):
import sys
from collections import Counter

n, k = map(int, input().split())
l_array = sorted(list(map(int, input().split())), reverse=True)

print(sum(l_array[:k]))

Solution (Python):

def read_input():
    n, k = map(int, input().split())
    llist = list(map(int, input().split()))

    return n, k, llist

def submit():
    n, k, llist = read_input()
    llist.sort()
    print(sum(llist[-k:]))



if __name__ == '__main__':
    submit()

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

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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, k =f()
    l = f()

    l = sorted(l, reverse = True)

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


solve()

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

ret = 0
for i in range(k):
    item = max(l)
    max_id = l.index(item)
    l[max_id] = -1
    ret += item
print(ret)

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())
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.sort(reverse=1)

print(sum(l[:K]))

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math


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

l.sort()
ans = sum(l[-K:])
print(ans)

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

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

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

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N,K = (int(_) for _ in input().split())
    l = list(int(_) for _ in input().split())
    l.sort()
    l=l[::-1]
    sum_l = 0
    for i in range(0,K):
        sum_l += l[i]
    print(sum_l)
    
if __name__ == '__main__':
    main()

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

print(x)

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

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

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

Solution (Python):
if __name__ == '__main__':
    n, k = [int(i) for i in input().split()]
    ls = [int(i) for i in input().split()]

    print(sum(sorted(ls, 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 = [int(n) for n in input().split()]
l = sorted([int(m) for m in input().split()], 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())
a=list(map(int,input().split()))
a.sort()
print(sum(a[n-k:]))

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

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