N, K = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) ans = A[0] for a in A: if a > 0: ans += a print(ans)