class Fenwick_Tree: def __init__(self, n): self.n = n self.data = [0] * n def add(self, p, x): p += 1 while p <= self.n: self.data[p - 1] += x p += p & -p def sum(self, l, r): '''範囲[l, r)(lからr-1まで)の総和を求める''' return self._sum(r) - self._sum(l) def _sum(self, r): '''範囲[0, r)(0からr-1まで)の総和を求める''' s = 0 while r > 0: s += self.data[r - 1] r -= r & -r return s n, q = map(int, input().split()) A = list(map(int, input().split())) Dif = [A[i + 1] - A[i] for i in range(n - 1)] FenTree = Fenwick_Tree(n - 1) for i in range(n - 1): if Dif[i] != 0: FenTree.add(i, 1) for _ in range(q): L = list(map(int, input().split())) if L[0] == 1: l, r, x = L[1:] l -= 2 if l >= 0: prev = Dif[l] curr = Dif[l] + x if prev == 0: FenTree.add(l, 1) elif curr == 0: FenTree.add(l, -1) Dif[l] = curr r -= 1 if r < n - 1: prev = Dif[r] curr = Dif[r] - x if prev == 0: FenTree.add(r, 1) elif curr == 0: FenTree.add(r, -1) Dif[r] = curr elif L[0] == 2: l, r = L[1:] if l == r: print(1) continue l -= 1 r -= 1 print(1 + FenTree.sum(l, r))