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