#include using namespace std; using lint = long long int; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i istream &operator>>(istream &is, vector &vec){ for (auto &v : vec) is >> v; return is; } template ostream &operator<<(ostream &os, const vector &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } #define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl; // 1-indexed BIT (i : [1, len]) template struct BIT { int len; vector val; BIT(int num) : len(num), val(num + 1) {} BIT() : BIT(0) {} void reset() { fill(val.begin(), val.end(), 0); } void add(int pos, T v) { while (pos > 0 and pos <= len) val[pos] += v, pos += pos & -pos; } T sum(int pos) const // (0, pos] { T res = 0; while (pos > 0) res += val[pos], pos -= pos & -pos; return res; } T get(int pos) const { return sum(pos) - sum(pos - 1); } }; int main() { int N, Q; cin >> N >> Q; vector A(N); cin >> A; BIT bit_d(N + 1); bit_d.add(1, A[0]); REP(i, N - 1) bit_d.add(i + 2, A[i + 1] - A[i]); BIT bit_n(N + 1); REP(i, N) if (bit_d.get(i + 1)) bit_n.add(i + 1, 1); REP(_, Q) { int q; cin >> q; if (q == 1) { int l, r, x; cin >> l >> r >> x; r++; if (bit_d.get(l)) bit_n.add(l, -1); bit_d.add(l, x); if (bit_d.get(l)) bit_n.add(l, 1); if (bit_d.get(r)) bit_n.add(r, -1); bit_d.add(r, -x); if (bit_d.get(r)) bit_n.add(r, 1); } else { int l, r; cin >> l >> r; int ret = bit_n.sum(r) - bit_n.sum(l - 1); if (bit_n.get(l) == 0) ret++; cout << ret << endl; } } }