ll@n,@x,A=0,l=0,@a[n];if(x<0){reverse(a,a+n);rep(i,n)a[i]*=-1;x=abs(x);}for(ll i:a)if(i>0)A+=max(min(x,i)-max(l,i-30),0),l=i;wt(A);