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