n,k = map(int, input().split()) l = list(map(int, input().split())) l = [max(x,0) for x in l] print(sum(l[:k]))