#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include #include using namespace std; using namespace atcoder; int op(ll x,ll y){return x+y;} int e(){return 0;} int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n,q; cin>>n>>q; vector A(n),B(n); rep(i,n) cin>>A[i]; for(int i=1;i seg(n); for(int i=1;i>c; if(c==1){ int l,r; ll x; cin>>l>>r>>x; l--,r; if(B[l]==0) seg.set(l,1); B[l]+=x; if(B[l]==0) seg.set(l,0); if(B[r]==0) seg.set(r,1); B[r]-=x; if(B[r]==0) seg.set(r,0); } else{ int l,r; cin>>l>>r; l--,r--; cout<<1+seg.prod(l+1,r+1)<<'\n'; } } return 0; }