#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using ll = long long; using P = std::pair; #define rep(i, a, b) for (ll(i) = (a); i < (b); i++) #define all(i) i.begin(), i.end() #define debug(i) std::cerr << "debug " << #i<<" "< std::ostream& operator<<(std::ostream& os, std::pair pa) { return os << pa.first << " " << pa.second; } template std::ostream& operator<<(std::ostream& os, std::vector vec) { for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " "); return os; } template inline bool chmax(T1& a,T2 b){return a inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);} ll pow_mod(ll a, ll b, ll mod=-1) { if ((a == 0)||(mod!=-1&&a%mod==0)) { return 0; } ll x = 1; while (b > 0) { if (b & 1) { x = (mod!=-1)?(x * a) % mod:x*a; } a = (mod!=-1)?(a * a) % mod:a*a; b >>= 1; } return x; } // const ll MOD = 998244353; const ll MOD = 1e9 + 7; //非再帰抽象セグ木 0-indexed 単位元はiで指定 template class SegmentTree { private: long long n; T init; std::vector dat; F fn; public: SegmentTree(long long i, T para, F fun) : init(para), fn(fun) { n = 1; while (n < i) { n *= 2; } dat = std::vector(2 * n - 1, init); } // k番目(0-indexed)を値aで更新,dest=trueのときは更新前を破壊する void update(long long k, T a, bool dest) { k += n - 1; if (dest) dat[k] = a; else dat[k] = fn(dat[k], a); while (k > 0) { k = (k - 1) / 2; dat[k] = fn(dat[k * 2 + 1], dat[k * 2 + 2]); } } T query(long long a, long long b){ assert(0<=a&&b<=n); T val=init; long long l=a+n-1,r=b+n-1; for(;l>1),r=(r>>1)){ if(!(r&1)){ r--; val=fn(val,dat[r]); } if(!(l&1)){ val=fn(val,dat[l]); l++; } } return val; } }; int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); ll n,q; std::cin>>n>>q; auto f=[](ll x,ll y){return x+y;}; SegmentTree a(n+2,0,f); std::vector diff(n); ll prev; std::cin>>prev; rep(i,0,n-1){ ll temp; std::cin>>temp; diff[i]=temp-prev; a.update(i,(temp==prev)?0:1,true); prev=temp; } a.update(n-1,0,true); rep(i,0,q){ ll query; std::cin>>query; if(query==1){ ll l,r,x; std::cin>>l>>r>>x; l--;r--; if(l!=0){ diff[l-1]+=x; a.update(l-1,(diff[l-1]!=0)?1:0,true); } if(r!=n-1){ diff[r]-=x; a.update(r,(diff[r]!=0)?1:0,true); } }else{ ll l,r; std::cin>>l>>r; l--;r--; if(l==r)std::cout<<1<<"\n"; else std::cout<