#include #include using namespace std; using namespace atcoder; using ll = long long; struct S{ ll l, r, c; }; using F = ll; S op(S l, S r){ return{ l.l, r.r, l.c+r.c+(l.r != r.l) }; } S e(){ return{ 0, 0, 0 }; } S mapp(F f, S x){ x.l += f, x.r += f; return x; } F comp(F f, F g){ return f+g; } F id(){ return 0; } int main(){ int N, Q; cin >> N >> Q; lazy_segtree seg(N); for (int i = 0; i < N; i++){ int x; cin >> x; seg.set(i, S{x, x, 0}); } while (Q--){ int t, l, r, x; cin >> t >> l >> r, l--; if (t == 1){ cin >> x; seg.apply(l, r, x); } else{ cout << seg.prod(l, r).c-1 << endl; } } }