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

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

L = list(map(int,input().split()))[:N]

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

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

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

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

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

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

Solution (Python):
import sys

stdin = sys.stdin

n,k = list(map(int, stdin.readline().split()))
l = list(map(int, 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()))
a = sorted(l)
ans = 0
for i in range(K):
    ans += a[-(i+1)]
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 = [0]*N
l = list(map(int,input().split()))
l.sort()
l_inv = [i for i in l[::-1]]
l_K = [i for i in l_inv[:K]]
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(reverse=True)
print(sum(l[:k]))

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

if len(l) > k:
    print(sum(sorted(l)[-k:]))
else:
    print(sum(l))

Solution (Python):
n, k = map(int, input().split())
l = list(map(int, input().split()))
for i in range(n - 1):
    for j in range(i + 1, n):
        if l[i] < l[j]:
            buf = l[i]
            l[i] = l[j]
            l[j] = buf
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)
total = 0
for x in range(k):
    total += l[x]
print(total)

Solution (Python):
import math
import sys

def getinputdata():

    
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

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

arr01=arr_data[1]

arr02=sorted(list(map(int, arr01)),reverse=True)



mysum=0
for v in range(0,len(arr02)):

    if(v!=k):
        mysum+=arr02[v]
   
        
    else:
        break
print(mysum)

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

    ans = sum(i for i in l[:K])

    print(ans)

if __name__ == "__main__":
    main()

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

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

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

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

Solution (Python):





if __name__ == '__main__':
    total_bar_count, choosed_bar_count = list(map(int, input().split()))
    bar_lengths = list(map(int, input().split()))

    bar_lengths.sort(reverse=True)
    total_bar_length = sum(bar_lengths[:choosed_bar_count])
    print(total_bar_length)

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

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

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

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

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

Solution (Python):
NK = raw_input()
li = raw_input()

N = int(NK.split()[0])
K = int(NK.split()[1])
li_list = li.split()
li_list = map(int, li_list)

cut_list = sorted(li_list, key=int, reverse=True)[0:K]


print(sum(cut_list))

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

for i in range(k):
    ans += max(l)
    l.remove(max(l))
print(ans)

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

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

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

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

print(T)

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

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

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

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

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

Solution (Python):

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

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

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

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

l.sort()
l.reverse()

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

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

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

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

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

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

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

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

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

l.sort()
l = list(reversed(l))
print(sum(l[:K]))

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

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

Solution (Python):
num = [int(x) for x in input().split()]
stick = [int(x) for x in input().split()]

stick = sorted(stick)

ret = 0
for i in reversed(range(len(stick)-num[1], len(stick))):
    ret += stick[i]
print(ret)

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

Solution (Python):


N,K=list( int(i) for i in input().split() )
l=list( int(i) for i in input().split() )

l.sort()
l.reverse()

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

print(N)

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

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

x = sorted(x, reverse=True)

summation = 0

for i in range(k):
    summation += x[i]

print(summation)

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

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

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

Solution (Python):

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

l.sort()
l.reverse()

re = 0
for i in l[:k]:
   re += i

print(re)

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

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

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

l.sort(reverse = True)

print(sum(l[: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())
L = [int(n) for n in input().split()]
sort = sorted(L, reverse=True)
length = 0
for i in range(K):
    length += sort[i]
print(length)

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

Solution (Python):

"""
http://abc067.contest.atcoder.jp/tasks/abc067_b

"""
import sys
from sys import stdin

input = stdin.readline


def main(args):
    N, K = map(int, input().split())
    rods = [int(x) for x in input().split()]
    rods.sort()
    snake = rods[-K:]
    print(sum(snake))


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
x = input().split()
y = input().split()
x = [int(x) for x in x]
y = [int(y) for y in y]
y = sorted(y,reverse=True)
i = 0 
j = 0
for num in y:
    i=i+num
    j+=1
    if j==x[1]:
        print(i)
        break

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

Solution (Python):
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
def solve():  
    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]))


solve()

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

l.sort()

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

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

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

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

if __name__ == "__main__":
    main()

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

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

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

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

print(sum)

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

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

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

print(sum)

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

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

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

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

Solution (Python):
def Q2(x):
    N, K = x[0][0], x[0][1]
    lst = x[1][:]
    lst = sorted(lst)[::-1]
    return sum(lst[:K])

l = [int(i) for i in input().split()]
m = [int(i) for i in input().split()]
n = [l,m]
print(Q2(n))

Solution (Python):
t = raw_input().split()
a = int(t[0])
b = int(t[1])
l = map(int, raw_input().strip().split())
l.sort()
l = l[::-1]
ans = 0
for x in range(b):
	ans += l[x]
print(ans)

Solution (Python):

N, K = map(int, input().split())
lens = [int(e) for e in input().split()]
lens.sort()
lens.reverse()

print(sum(lens[:K]))

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

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

Solution (Python):
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
cnt = 0
ans = 0
l.sort()
for i in reversed(l):
    if cnt < k:
        ans += i
        cnt += 1
    else:
        break
print(ans)

Solution (Python):



n_k = raw_input()
n_k = n_k.split()
n_k = map(int,n_k)
n = n_k[0]
k = n_k[1]

l = raw_input()
l = l.split()
l = map(int,l)

ans = 0
i = 0
while i < k:
    max_len = max(l)
    ans += max_len
    l[l.index(max_len)] = 0
    i += 1

print ans

Solution (Python):


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

Solution (Python):
def snake_toy():
	n, k = map(int, raw_input().split(" "))
	l = list(map(int, raw_input().split(" ")))
	sorted_l = sorted(l, reverse=True)
	print sum(sorted_l[:k])


if __name__ == "__main__":
	snake_toy()

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

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

Solution (Python):
m, n = map(int, input().split())
M = list(map(int, input().split()))
M.sort()
M.reverse()
A = []
for i in range(n):
    A.append(M[i])
print(sum(A))

Solution (Python):



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

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

print SUM

Solution (Python):

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

N = a[0]
K = a[1]
sub = N - K

b = list(map((int),input().split(' ')))


for i in range(sub):
    b.pop(b.index(min(b)))
    
print(sum(b))

Solution (Python):


a=input()
b=a.split(" ")
N=int(b[0])
K=int(b[1])
ans=[]
c=input()
l=c.split(" ")
l1=map(int,l)
l2=list(l1)
for w in range(K):
    ans.append(max(l2))
    max_idx = l2.index(max(l2))
    del l2[max_idx]
print(sum(ans))

Solution (Python):
import numpy as np
N, K = map(int, input().split())
L = list(map(int, input().split()))
L = sorted(L, reverse=True)
L = np.array(L)
print(np.sum(L[:K]))

Solution (Python):
(n, k) = tuple(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()))
 
a = sorted(L)
 
print(sum(a[-K:]))

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

lsort = sorted(l, reverse=True)

lsum = 0
for i in range(k):
    lsum = lsum + lsort[i]
print(lsum)

Solution (Python):
line = input().split()
N = int(line[0])
K = int(line[1])
l = sorted(map(int, input().split()), key=lambda x: -x)
ans = 0

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

print(ans)

Solution (Python):



import sys

input_line = sys.stdin.readline().split(' ')
n = int(input_line[0])
k = int(input_line[1])

input_line = sys.stdin.readline().split(' ')
l_list = list(map(int, input_line))

l_list.sort(reverse=True)

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

print(l)

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

print(goukei)

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

print(sum(sorted(l)[:-(K+1):-1]))

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

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

Solution (Python):
N, K = list(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, raw_input().split(" "))
numbers = map(int, raw_input().split(" "))
numbers.sort()

print sum(numbers[-k:])

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

Solution (Python):
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

n, k = rli()
s = rli()
s.sort(reverse=True)
print(sum(s[:k]))

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

nums.sort()
nums.reverse()
ans=list()

for v in range(k):
    ans.append(nums[v])

print(sum(ans))

Solution (Python):
m, n = map(int, input().split())
M = list(map(int, input().split()))
M.sort()
M.reverse()
A = []
for i in range(n):
    A.append(M[i])
print(sum(A))

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

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

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

l = sorted(l)

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

print(ans)

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

Solution (Python):
list = input().rstrip().split()
N = int(list[0])
K = int(list[1])
list2 = input().rstrip().split()
a = []
for i in range(N):
    a = a + [int(list2[i])]
a.sort()
sum = 0
for i in range(K):
    sum = sum + a[N-1-i]
print(sum)

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

l.sort(reverse = True)
ans = 0

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

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

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

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

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

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

mainB()

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

Solution (Python):
m, n = map(int, input().split())
M = list(map(int, input().split()))
M.sort()
M.reverse()
A = []
for i in range(n):
    A.append(M[i])
print(sum(A))

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

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

Solution (Python):
n, k =map( int, raw_input().split())
l =map( int, raw_input().split())
L = sorted(l)[::-1]
print '{}'.format(sum(L[:k]))

Solution (Python):


import re

n, k = map(int, re.split('\s', raw_input()))
l = map(int, re.split('\s', raw_input()))
ans = 0

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

print ans

Solution (Python):
arr = raw_input().split(' ')
n = int(arr[0])
k = int(arr[1])
l = raw_input().split(' ')
l = map(int,l)
l.sort()
for i in l:
	i = int(i)
ans = 0
for i in range(n-k, n):
	ans = l[i] + ans
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())
lengths = map(int,input().split())

lengths = sorted(lengths)
result = 0
for i in range(len(lengths)-1,len(lengths)-1-K,-1):
    result += lengths[i]
print(result)

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

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

sort_l = sorted(l, reverse = True)

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

print(sum)

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

Solution (Python):
Imp = list(map(int, input().split()))
Blist = list(map(int, input().split()))
Blist.sort()

out = 0
for i in range(Imp[1]):
    out += Blist[-(i+1)]
    
print(out)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,k = LI()
    a = sorted(LI(),reverse=True)

    return sum(a[:k])


print(main())

Solution (Python):
from sys import stdin
n,k = map(int,stdin.readline().split())
a = map(int,stdin.readline().split())
a.sort()
a.reverse()
print sum(a[:k])

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

Solution (Python):
if __name__ == "__main__":
    N, K = list(map(int, input().split()))
    data = list(map(int, input().split()))
    data.sort(reverse = True)
    result = sum(data[:K])
    print(result)

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

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

l.sort()
l.reverse()

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

Solution (Python):
n,m=map(int,raw_input().split())
s=raw_input().split()
a=[]
t=[0 for i in range(n)]
for i in range(n):
    a.append(int(s[i]))
sum=0
a=sorted(a)
for j in range(n-1,n-m-1,-1):
    sum=sum+a[j]
print sum

Solution (Python):
import numpy as np

nk = input().split(' ')
n, k = (int(nk[0]), int(nk[1]))
l = [int(num) for num in input().split(' ')]
max = 0
for _ in range(k):
    m = np.array(l).max()
    max += m
    l.remove(m)
print(max)

Solution (Python):


n,k=map(int,raw_input().split())
l=map(int,raw_input().split())
l=sorted(l,reverse=True)
res=0
for i in xrange(k):
 res+=l[i]
print res

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


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

print(sum)

Solution (Python):
N,K=map(int,input().split())
l=list(map(int,input().split()))
S=0
for i in range(K):
    S+=max(l)
    l.remove(max(l))
print(S)

Solution (Python):



from collections import defaultdict
from math import factorial as f
from fractions import gcd as g

n, k = [int (i)  for i in raw_input ().split ()]
a = [int (i)  for i in raw_input ().split ()]
a.sort (reverse = True)
print sum (a [:k])

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

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

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

print(sum(sorted_l[:K]))

Solution (Python):
inpt = map(int, raw_input().split())
n = inpt[0]
k = inpt[1]
lst = map(int, raw_input().split())
lst.sort()
ans = 0
for i in range(0, k):
	ans += lst[-1-i]
print ans

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

import sys

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

l.sort()
s = 0
for i in range(K):
    s += l[N-K+i]

print(s)

Solution (Python):
def solution(n, k, l_list):
    l_list.sort(reverse=True)
    result = sum(l_list[:k])
    return result


N, K = [int(value) for value in input().split(' ')]
l_list = [int(value) for value in input().split(' ')]
print(solution(N, K, l_list))

Solution (Python):
def read(): return list(map(int, input().split()))

n, k = read()
l = read()
print(sum(sorted(l)[::-1][:k]))

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

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

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

len_list.sort(reverse=True)

print(sum(len_list[:k]))

Solution (Python):
N_K = map(int, raw_input().split())

l = map(int, raw_input().split())
l.sort()
l.reverse()

ans = 0

for i in range(N_K[1]):
    ans += int(l[i])

print ans

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

Solution (Python):
import sys




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


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n, k = read_int_list()
    l = read_int_list()
    l.sort()
    res = sum([i for i in l[-k:]])
    print(res)


main()

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

l = map(int, raw_input().split())

l.sort()
l.reverse()

ans = 0

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

print ans

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

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

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

Solution (Python):
sticks_canJoinNum = input()
str_stickLength = input()

sticks_num = int(sticks_canJoinNum.split()[0])
num_canJoin = int(sticks_canJoinNum.split()[1])
stick_list = [int(i) for i in str_stickLength.split()]

stick_list.sort(reverse=True)
max_length = sum(stick_list[:num_canJoin])
print(max_length)

Solution (Python):
a=input().split()
b=input().split()
N=int(a[0])
K=int(a[1])
c=[]
s=0

for i in range(N):
 l=int(b[i])
 c.append(l)
c.sort(reverse=True)
for i in range(K):
 s +=c[i]
print(s)

Solution (Python):
a=input().split()
b=input().split()
N=int(a[0])
K=int(a[1])
c=[]
s=0

for i in range(N):
 l=int(b[i])
 c.append(l)
c.sort(reverse=True)
for i in range(K):
 s +=c[i]
print(s)

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

l.sort(reverse=True)
for num in range(K):
    res = res + l[num]
print(str(res))

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

H.sort(reverse=True)

A=H[0:K]
B=sum(A)

print(B)

Solution (Python):
ab = input().split(' ')
st = input().split(' ')
st = [int(x) for x in st]
k = int(ab[1])
max1 =0
pl = sum(st)
for i in range(int(ab[0])-k):
    pl -= min(st)
    del st[st.index(min(st))]


        
print(pl)