# _*_ coding:utf-8 _*_

#  Atcoder_Beginners_Contest067-B

#  TODO https://atcoder.jp/contests/abc067/tasks/abc067_b

import time

from contextlib import contextmanager

# from time import sleep

@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 = list(range(0,needBarNumber,+1))

	longLength = 0

	for i in getBarCountRange:

		longLength = longLength + longSortedToyList[i]

	answer = longLength

	return answer





if __name__ == '__main__':

	_,K = list(map(int,input().strip().split(' ')))

	lengthList = list(map(int,input().strip().split(' ')))

	solution=calcLongSnakeToy(K,lengthList)

	print(("{}".format(solution)))
# Problem: https://atcoder.jp/contests/abc067/tasks/abc067_b

# Python 1st Try



import sys

# from collections import defaultdict

# import heapq,copy

# from collections import deque





def II(): return int(sys.stdin.readline())





def MI(): return list(map(int, sys.stdin.readline().split()))





def LI(): return list(map(int, sys.stdin.readline().split()))





def LLI(rows_number): return [LI() for _ in range(rows_number)]





def solver(selectNum, barLongth):

    result = 0

    barLongth.sort(reverse=True)

    #   print("{}".format(barLongth))

    # algorithm

    j = 0

    while j < selectNum:

        result = result + barLongth[j]

        j = j + 1

    return result





if __name__ == "__main__":

    _, K = MI()  # Nは要らない

    LII = LI()

    print(("{}".format(solver(K, LII))))

# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest067-B
#  TODO https://atcoder.jp/contests/abc067/tasks/abc067_b
import time
from contextlib import contextmanager

# from time import sleep
@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 = list(range(0, needBarNumber, +1))
    longLength = 0
    for i in getBarCountRange:
        longLength = longLength + longSortedToyList[i]
    answer = longLength
    return answer


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

# Problem: https://atcoder.jp/contests/abc067/tasks/abc067_b
# Python 1st Try
import sys

# from collections import defaultdict
# import heapq,copy
# from collections import deque
def II():
    return int(sys.stdin.readline())


def MI():
    return list(map(int, sys.stdin.readline().split()))


def LI():
    return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number):
    return [LI() for _ in range(rows_number)]


def solver(selectNum, barLongth):
    result = 0
    barLongth.sort(reverse=True)
    #   print("{}".format(barLongth))
    # algorithm
    j = 0
    while j < selectNum:
        result = result + barLongth[j]
        j = j + 1
    return result


if __name__ == "__main__":
    _, K = MI()  # Nは要らない
    LII = LI()
    print(("{}".format(solver(K, LII))))

-# _*_ coding:utf-8 _*_ -#  Atcoder_Beginners_Contest067-B -#  TODO https://atcoder.jp/contests/abc067/tasks/abc067_b -import time -from contextlib import contextmanager +# Problem: https://atcoder.jp/contests/abc067/tasks/abc067_b +# Python 1st Try +import sys -# from time import sleep -@contextmanager -def timer(title): -    t0 = time.time() -    yield -    print(("{} - done in {:.0f}s".format(title, time.time() - t0))) +# from collections import defaultdict +# import heapq,copy +# from collections import deque +def II(): +    return int(sys.stdin.readline()) -def calcLongSnakeToy(needBarNumber, barLengthList): -    longSortedToyList = sorted(barLengthList, reverse=True) -    getBarCountRange = list(range(0, needBarNumber, +1)) -    longLength = 0 -    for i in getBarCountRange: -        longLength = longLength + longSortedToyList[i] -    answer = longLength -    return answer +def MI(): +    return list(map(int, sys.stdin.readline().split())) + + +def LI(): +    return list(map(int, sys.stdin.readline().split())) + + +def LLI(rows_number): +    return [LI() for _ in range(rows_number)] + + +def solver(selectNum, barLongth): +    result = 0 +    barLongth.sort(reverse=True) +    #   print("{}".format(barLongth)) +    # algorithm +    j = 0 +    while j < selectNum: +        result = result + barLongth[j] +        j = j + 1 +    return result -    _, K = list(map(int, input().strip().split(" "))) -    lengthList = list(map(int, input().strip().split(" "))) -    solution = calcLongSnakeToy(K, lengthList) -    print(("{}".format(solution))) +    _, K = MI()  # Nは要らない +    LII = LI() +    print(("{}".format(solver(K, LII))))