#include #include using namespace std; typedef long long LL; const int N = 100010; LL cf[N]; int n, q, a[N]; struct BIT { LL tr[N]; int LowBit(int x) { return x & -x; } void Add(int x, int v) { for (int i = x; i <= n; i += LowBit(i)) tr[i] += v; } LL Sum(int x) { LL ret = 0LL; for (int i = x; i; i -= LowBit(i)) ret += tr[i]; return ret; } }; BIT bit; void Modify(int x, LL v) { if (cf[x] != 0) bit.Add(x, -1); cf[x] += v; if (cf[x] != 0) bit.Add(x, 1); } int main() { scanf("%d%d", &n, &q); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); for (int i = 2; i <= n; ++i) { cf[i] = a[i] - a[i - 1]; if (cf[i] != 0) bit.Add(i, 1); } while (q--) { int op, l, r; scanf("%d%d%d", &op, &l, &r); if (op == 1) { LL x; scanf("%lld", &x); if (l > 1) Modify(l, x); if (r < n) Modify(r + 1, -x); } else { printf("%lld\n", bit.Sum(r) - bit.Sum(l) + 1); } } return 0; }