n,k=map(int,input().split()) lst=sorted(map(int,input().split()),reverse=True) print(lst[0]+sum(lst[1:k-1]))