from sys import stdin def main(): input = lambda: stdin.readline()[:-1] N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=1) print(sum(A[:K])) main()