#include using namespace std; typedef long long ll; typedef pair pii; typedef pair pll; #define LLINF 9223372036854775807 #define MOD ll(1e9+7) #define all(x) (x).begin(),(x).end() #define dbg(x) cerr<<#x<<": "< &v){ n = 1; while(n < size){n *= 2;} data = vector(2*n-1, MAX_NUM); build(v); } void build(vector &v){ for(int i = 0; i < v.size(); i++){ data[n-1+i] = v[i]; } for(int i = n-2; i >= 0; i--){ data[i] = data[2*i+1] + data[2*i+2]; } } void update(ll k, ll a){ k += n-1; data[k] = a; while(k>0){ k = (k-1)/2; data[k] = data[2*k+1] + data[2*k+2]; } } ll getSize(){return n;} ll getData(ll x){return data[n-1+x];} ll query(ll a, ll b, ll k, ll l, ll r){ if(r <= a || b <= l){return 0;} if(a <= l && r <= b){return data[k];} else{ ll vl = query(a, b, 2*k+1, l, (l+r)/2); ll vr = query(a, b, 2*k+2, (l+r)/2, r); return vl + vr; } } void printAllTree(){ ll cnt = 0; ll br = 1; for(int i = 0; i < data.size(); i++){ cout << data[i] << " "; cnt++; if(cnt == br){ cout << endl; cnt = 0; br *= 2; } } } private: ll n; vector data; ll MAX_NUM = 1LL << 60; }; int main(){ ll n, q; cin >> n >> q; vector a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } vector diff(n,1LL<<60); vector same(n,0); for(int i = 0; i < n-1; i++){ diff[i] = a[i+1] - a[i]; same[i] = (diff[i] == 0) ? 1 : 0; } segtree st(n, same); for(int i = 0; i < q; i++){ ll ta, tl, tr, tx; cin >> ta; if(ta==1){ cin >> tl >> tr >> tx; tl--; tr--; if(tl != 0){ diff[tl-1] += tx; same[tl-1] = (diff[tl-1] == 0) ? 1 : 0; st.update(tl-1, same[tl-1]); } if(tr != n-1){ diff[tr] -= tx; same[tr] = (diff[tr] == 0) ? 1 : 0; st.update(tr, same[tr]); } }else{ cin >> tl >> tr; tl--; tr--; ll ret = st.query(tl, tr, 0, 0, st.getSize()); cout << (tr-tl) - ret + 1 << endl; } } return 0; }