#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(x<0?0:x,a)-max({x<0?x:0,a-30,f}));cout<