M, K = map(int, input().split()) A = list(map(int, input().split())) A.sort(reversed=True) print(sum(A[:K]))