#include using namespace std; template struct SegmentTree { using F = function; const T init; const F f; int sz; vector seg; SegmentTree(int n, const T init, const F f) : init(init), f(f) { sz = 1; while(sz < n) sz <<= 1; seg.resize(sz << 1, init); } void update(int id) { while(id >>= 1) { seg[id] = f(seg[2 * id], seg[2 * id + 1]); } } void replace(int id, T x){ id += sz; seg[id] = x; update(id); } // [l,r) T get(int l, int r){ T L = init, R = init; for(l += sz, r += sz; l < r; l >>= 1, r>>= 1) { if(l & 1) L = f(L, seg[l++]); if(r & 1) R = f(seg[--r], R); } return f(L, R); } void debug(){ int i = 1; for(int r = 2; r <= 2 * sz; r <<= 1) { while(i < r) { cout << seg[i++] << " "; } cout << "\n"; } } }; int main() { int n, q; cin >> n >> q; int64_t a[n]; for(int i = 0; i < n; ++i) cin >> a[i]; int64_t b[n - 1]; SegmentTree seg(n - 1, 0, [](int lhs, int rhs){return lhs + rhs;}); for(int i = 0; i < n - 1; ++i) { b[i] = a[i] - a[i + 1]; if(b[i] != 0) seg.replace(i, 1); } while(q--) { int qq; cin >> qq; int l, r; cin >> l >> r; --l, --r; if(qq == 1) { int64_t x; cin >> x; if(l - 1 >= 0) { b[l - 1] -= x; seg.replace(l - 1, (b[l - 1] != 0 ? 1 : 0)); } if(r < n - 1) { b[r] += x; seg.replace(r, (b[r] != 0 ? 1 : 0)); } } if(qq == 2) { cout << seg.get(l, r) + 1 << '\n'; } } return 0; }