m,n=map(int,input().split()) s=0 l=list(map(int,input().split())) max=0 for i in range(m): if l[i]>=0: s+=l[i] else: if s>max: max=s s=0 print(s)