#import using namespace std;int x,a,q,f=-2e9;main(){for(cin>>x>>x;cin>>a;f=a)a+=(x<0)*30,q+=max(0,min(max(0,x),a)-max({min(0,x),a-30,f}));cout<