N, K, *A = map(int, open(0).read().split()) A.sort(reverse=True) print(sum(max(0, a) for a in A[:K]))