#include #define rep(i,n) for(int i=0;i<(n);++i) using namespace std; using ll = long long; template struct lazy_segtree { public: lazy_segtree() : lazy_segtree(0) {} explicit lazy_segtree(int n) : lazy_segtree(std::vector(n, e())) {} explicit lazy_segtree(const std::vector& v) : _n(int(v.size())) { size = (int)bit_ceil(_n); log = countr_zero(size); d = std::vector(2 * size, e()); lz = std::vector(size, id()); for (int i = 0; i < _n; i++) d[size + i] = v[i]; for (int i = size - 1; i >= 1; i--) { update(i); } } void set(int p, S x) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); d[p] = x; for (int i = 1; i <= log; i++) update(p >> i); } S get(int p) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); return d[p]; } S prod(int l, int r) { assert(0 <= l && l <= r && r <= _n); if (l == r) return e(); l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push((r - 1) >> i); } S sml = e(), smr = e(); while (l < r) { if (l & 1) sml = op(sml, d[l++]); if (r & 1) smr = op(d[--r], smr); l >>= 1; r >>= 1; } return op(sml, smr); } S all_prod() { return d[1]; } void apply(int p, F f) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); d[p] = mapping(f, d[p]); for (int i = 1; i <= log; i++) update(p >> i); } void apply(int l, int r, F f) { assert(0 <= l && l <= r && r <= _n); if (l == r) return; l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push((r - 1) >> i); } { int l2 = l, r2 = r; while (l < r) { if (l & 1) all_apply(l++, f); if (r & 1) all_apply(--r, f); l >>= 1; r >>= 1; } l = l2; r = r2; } for (int i = 1; i <= log; i++) { if (((l >> i) << i) != l) update(l >> i); if (((r >> i) << i) != r) update((r - 1) >> i); } } private: int _n, size, log; std::vector d; std::vector lz; void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); } void all_apply(int k, F f) { d[k] = mapping(f, d[k]); if (k < size) { lz[k] = composition(f, lz[k]); } } void push(int k) { all_apply(2 * k, lz[k]); all_apply(2 * k + 1, lz[k]); lz[k] = id(); } static int bit_ceil(int x) { return 1 << (32 - __builtin_clz(x - 1)); } static int countr_zero(int x) { return __builtin_ctz(x); } }; struct S{ ll a,l,r; }; S op(S a, S b){ if(a.a==-1) return b; if(b.a==-1) return a; S s; s.a=a.a+b.a; if(a.r!=b.l)s.a++; s.l=a.l; s.r=b.r; return s; } S e(){ return S{-1,-1,-1}; } using F = ll; S mapping(F f, S s){ s.l+=f; s.r+=f; return s; } F composition(F f, F g){ return f+g; } F id(){ return 0; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,q; cin>>n>>q; vector a(n); rep(i,n)cin>>a[i]; vector init(n); rep(i,n){ init[i].a=0; init[i].l=a[i]; init[i].r=a[i]; } lazy_segtree seg(init); rep(qi,q){ int t,l,r; cin>>t>>l>>r; l--;r--; if(t==1){ int x; cin>>x; seg.apply(l,r+1,x); } if(t==2){ cout<