#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll=long long; template using V = vector; template using P = pair; using vll = V; using vvll = V; #define rep(i, k, n) for (ll i=k; i<(ll)n; ++i) #define REP(i, n) rep(i, 0, n) #define ALL(v) v.begin(),v.end() template inline bool chmax(T& a, T b) {if (a inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;} const ll MOD = 1000000007; const ll HIGHINF = (ll)1e18; template < typename T > struct SegmentTree { vector data; long long n; SegmentTree(vector vec) { long long sz = vec.size(); n=1; while(n=0; i--) data[i] = data[2*i+1] + data[2*i+2]; } void update(long long x, T val) { x += (n-1); data[x] = val; while(x > 0) { x = (x-1) / 2; data[x] = data[2*x+1] + data[2*x+2]; } } T query(long long l, long long r) { T ret = 0; l += (n-1), r += (n-1); while (l < r) { if ((l & 1LL) == 0LL) ret += data[l]; if ((r & 1LL) == 0LL) ret += data[r-1]; l /= 2; r = (r-1) / 2; } return ret; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, q; cin >> n >> q; vll a(n); REP(i, n) cin >> a[i]; vll aa(n-1, 0); REP(i, n-1) aa[i] = a[i] - a[i+1]; vll aaa(n-1, 0); REP(i, n-1) aaa[i] = aa[i]==0?0:1; SegmentTree seg(aaa); REP(_, q) { ll qi; cin >> qi; if (qi == 1) { ll l, r, x; cin >> l >> r >> x; l--; if (l > 0) { aa[l-1] -= x; aaa[l-1] = aa[l-1]==0?0:1; seg.update(l-1, aaa[l-1]); } if (r < n) { aa[r-1] += x; aaa[r-1] = aa[r-1]==0?0:1; seg.update(r-1, aaa[r-1]); } } else { ll l, r; cin >> l >> r; cout << seg.query(l-1, r-1)+1 << '\n'; } } return 0; }