#include "bits/stdc++.h" // Begin Header {{{ #define let const auto #define all(x) (x).begin(), (x).end() #define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i) #define reps(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i) #define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i) #define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__) #define lowerBound(...) lowerBound_(__VA_ARGS__) #define upperBound(...) upperBound_(__VA_ARGS__) #define lowerBound_(begin, end, ...) (lower_bound((begin), (end), __VA_ARGS__) - (begin)) #define upperBound_(begin, end, ...) (upper_bound((begin), (end), __VA_ARGS__) - (begin)) #ifdef DBG #define trace(...) trace_g(#__VA_ARGS__, __VA_ARGS__) #else #define trace(...) #endif using namespace std; using i64 = int_fast64_t; using pii = pair; templateinline bool chmax(T &a, const U &b){return b>a && (a=b, true);} templateinline bool chmin(T &a, const U &b){return b> 1); } inline i64 updiv(i64 a, i64 b) { return (a + b - 1) / b; } inline i64 sqr(i64 n) { return n * n; } inline string to_string(char c) { return string(1, c); } inline bool isRangeIn(i64 a, i64 low, i64 high) { return (low <= a && a <= high); } constexpr int INF = 0x3f3f3f3f; constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL; template vector makeVec(size_t sz) { return vector(sz); } template auto makeVec(size_t sz, Args... args) { return vector(args...))>(sz, makeVec(args...)); } template inline void input(T &x) { cin >> x; } template inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); } inline void print() { cout << "\n"; } template inline void print(Head &&head, Tail&&... tail) { cout << head; if (sizeof...(tail)) cout << ' '; print(forward(tail)...); } template ostream& operator<< (ostream &out, const vector &vec) { static constexpr const char *delim[] = { " ", "" }; for (const auto &e : vec) out << e << delim[&e == &vec.back()]; return out; } template ostream& operator<< (ostream &out, const vector> &mat) { static constexpr const char *tail[] = { "\n", "" }; for (const auto &row : mat) out << row << tail[&row == &mat.back()]; return out; } template void trace_g(const char *s, T&& x) { clog << '{'; while(*s != '\0') clog << *(s++); clog << ":" << setw(3) << x << '}' << endl; } template void trace_g(const char *s, Head&& head, Tail&&... tail) { clog << '{'; while(*s != ',') clog << *(s++); clog << ":" << setw(3) << head << "}, "; for (++s; !isgraph(*s); ++s); trace_g(s, std::forward(tail)...); } // }}} End Header template struct FenwickTree { // {{{ vector dat; const int SIZE_POW2; explicit FenwickTree(int size) noexcept : dat(size+5, 0), SIZE_POW2(32 - __builtin_clz(size)) {} inline void add(int i, const T &v) noexcept { for (++i; i < dat.size(); i += i & -i) dat[i]+=v; } inline T operator[](int i) const noexcept { return sum(i, i); } inline void update(int i, const T &newVal) noexcept { const auto curVal = this->operator[](i); add(i, newVal - curVal); } inline T sum(int i) const noexcept { T s = 0; for (++i; i > 0; i -= i & -i) s += dat[i]; return s;; } inline T sum(int s, int t) const noexcept { if (s > t) swap(s, t); return sum(t) - sum(s - 1); } inline int lower_bound(T v) const noexcept { if (v <= 0) return 0; int i = 0; for (int w = SIZE_POW2; w > 0; w >>= 1) { if (i + w < dat.size() && dat[i + w] < v) { v -= dat[i + w]; i += w; } } return i; } }; // }}} signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); var(int, N, Q); vector a(N); rep(i, N) input(a[i]); vector d(N - 1); FenwickTree ft(N - 1); rep(i, N - 1) { d[i] = a[i + 1] - a[i]; ft.add(i, (d[i] == 0 ? 0 : 1)); } while (Q--) { var(int, com, l, r); --l, --r; if (com == 1) { var(i64, x); if (l > 0) { d[l - 1] += x; ft.update(l - 1, d[l - 1] == 0 ? 0 : 1); } if (r < N - 1) { d[r] -= x; ft.update(r, d[r] == 0 ? 0 : 1); } } else { print(1 + ft.sum(l, r - 1)); } } return 0; }