#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; //#define int long long typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; const ll mod = 998244353; const ll INF = mod * mod; typedef pair P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef pair LP; typedef vector vec; typedef long double ld; typedef pair LDP; const ld eps = 1e-5; const ld pi = acos(-1.0); struct BIT { private: vector node; int n; public: BIT(int n_) { n = n_; node.resize(n, 0); } //0-indexed void add(int a, ll w) { for (int i = a; i < n; i |= i + 1)node[i] += w; } //[0,a) ll sum(int a) { ll ret = 0; for (int i = a - 1; i >= 0; i = (i&(i + 1)) - 1)ret += node[i]; return ret; } //[a,b) ll sum(int a, int b) { return sum(b) - sum(a); } }; void solve() { int n, q; cin >> n >> q; BIT b(n - 1); vector a(n); rep(i, n) { cin >> a[i]; } vector d(n-1); rep(i, n - 1) { d[i] = a[i + 1] - a[i]; if (d[i] != 0) { b.add(i, 1); } } rep(i, q) { int t; cin >> t; if (t == 1) { int l, r; ll x; cin >> l >> r >> x; l--; r--; if (l > 0) { d[l - 1] += x; if (d[l - 1] == x) { b.add(l - 1, 1); } else if(d[l-1]==0){ b.add(l - 1, -1); } } if (r < n - 1) { d[r] += x; if (d[r] == x) { b.add(r, 1); } else if(d[r]==0){ b.add(r, -1); } } } else { int l, r; cin >> l >> r; l--; r--; int ans = 1 + b.sum(l, r); cout << ans << endl; } } } signed main() { ios::sync_with_stdio(false); cin.tie(0); //cout << fixed << setprecision(50); //init(); solve(); //cout << "finish" << endl; //stop return 0; }