import sys input = sys.stdin.readline N,K=map(int,input().split()) A=list(map(int,input().split())) B = sorted(A[1:], reverse=True) print(sum(B[:K]))