N,X,*A=map(int,open(0).read().split()) if X<0:A=[-a for a in A][::-1];X=-X t=0 print(sum(max(-max(0,t,a-30)+min(X,t:=a),0)for a in A))