import sys input = sys.stdin.buffer.readline class Bit: """1-indexed""" def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def __getitem__(self, item): return self.sum(item, item) def initialize(self, A): for i, a in enumerate(A, 1): self.tree[i] = a j = (i & -i) >> 1 while j: self.tree[i] += self.tree[i - j] j >>= 1 def _sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def sum(self, i, j): """閉区間[i, j]""" return self._sum(j) - self._sum(i - 1) def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i N, Q = map(int, input().split()) A = tuple(map(int, input().split())) diff = [A[i + 1] - A[i] for i in range(N - 1)] bit = Bit(N - 1) bit.initialize(int(bool(x)) for x in diff) for _ in range(Q): query = tuple(map(int, input().split())) if query[0] == 1: l, r, x = query[1:] if l != 1: diff[l - 2] += x bit.add(l - 1, int(bool(diff[l - 2])) - bit[l - 1]) if r != N: diff[r - 1] -= x bit.add(r, int(bool(diff[r - 1])) - bit[r]) else: l, r = query[1:] print(bit.sum(l, r - 1) + 1)