#include #include #include #include #include #include #include #include #define rep(i,n) for (int i = 0; i < (int)n; i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair pi; typedef pair pp; typedef pair pl; double PI = 3.1415926535897932; const double EPS = 1e-9; const ll MOD = 1000000007; const int inf = 1 << 30; const ll linf = 1LL << 60; // 区間和、要素更新のsegtree template struct segtree { int n; vector dat; void init(int n_){ n = 1; while(n < n_) n *= 2; dat.assign(2*n-1, 0); } void update(int k, T a){ k += n-1; dat[k] += a; while(k > 0){ k = (k-1)/2; dat[k] = dat[k*2+1] + dat[k*2+2]; } } //(a,b,0,0,seg.n)で呼ぶ T query(int a, int b, int k, int l, int r){ if(r <= a || b <= l) return 0; if(a <= l && r <= b) return dat[k]; else{ T vl = query(a,b,k*2+1,l,(l+r)/2); T vr = query(a,b,k*2+2,(l+r)/2,r); return vl + vr; } } }; segtree seg; int n, q; ll a[100000]; ll d[100000]; int main() { cin >> n >> q; seg.init(n); rep(i,n) { cin >> a[i]; if (i > 0) { d[i-1] = a[i]-a[i-1]; if (d[i-1] != 0) seg.update(i-1, 1); } } rep(i,q) { int f; cin >> f; if (f == 1) { int l, r, x; cin >> l >> r >> x; l--; r--; if (l > 0) { if (d[l-1] != 0) seg.update(l-1, -1); d[l-1] += x; if (d[l-1] != 0) seg.update(l-1, 1); } if (r != n-1) { if (d[r] != 0) seg.update(r, -1); d[r] -= x; if (d[r] != 0) seg.update(r, 1); } } else { int l, r; cin >> l >> r; l--; r--; cout << seg.query(l, r, 0, 0, seg.n) + 1 << endl; } } }