#ifndef LOCAL #include using namespace std; #define debug(...) (void(0)) #else #include "algo/debug.h" #endif #include int op(int a, int b) { return a + b; } int e() { return 0; } void solve() { int N, Q; cin >> N >> Q; vector A(N); for (int i = 0; i < N; i++) cin >> A[i]; vector diff(N); for (int i = 1; i < N; i++) diff[i] = A[i] - A[i - 1]; vector B(N); for (int i = 1; i < N; i++) { B[i] = diff[i] != 0; } atcoder::segtree seg(B); auto Update = [&](int i) -> void { if (diff[i] == 0) seg.set(i, 0); else seg.set(i, 1); }; while (Q--) { int t; cin >> t; int l, r; cin >> l >> r; if (t == 1) { int x; cin >> x; l--; if (l != 0) { diff[l] += x; Update(l); } if (r != N) { diff[r] -= x; Update(r); } } else { cout << seg.prod(l, r) + 1 << endl; } } } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int tt = 1; // std::cin >> tt; while (tt--) { solve(); } }