#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines class BinaryIndexedTree(): def __init__(self, seq): self.size = len(seq) self.depth = self.size.bit_length() self.build(seq) def build(self, seq): data = seq size = self.size for i, x in enumerate(data): j = i + (i & (-i)) if j < size: data[j] += data[i] self.data = data def __repr__(self): return self.data.__repr__() def get_sum(self, i): data = self.data s = 0 while i: s += data[i] i -= i & -i return s def add(self, i, x): data = self.data size = self.size while i < size: data[i] += x i += i & -i def find_kth_element(self, k): data = self.data size = self.size x, sx = 0, 0 dx = 1 << (self.depth) for i in range(self.depth - 1, -1, -1): dx = (1 << i) if x + dx >= size: continue y = x + dx sy = sx + data[y] if sy < k: x, sx = y, sy return x + 1 N, Q = map(int, readline().split()) A = (0,) + tuple(map(int, readline().split())) + (0,) add = BinaryIndexedTree([0] * (N + 2)) is_equal = [0 if x != y else 1 for x, y in zip(A, A[1:])] + [0] is_equal_bit = BinaryIndexedTree(is_equal[:]) for query in readlines(): if query.startswith(b'1'): _, L, R, x = map(int, query.split()) add.add(L, x) add.add(R + 1, -x) for n in (L - 1, R): if is_equal[n]: is_equal[n] = 0 is_equal_bit.add(n, -1) else: if A[n] + add.get_sum(n) == A[n + 1] + add.get_sum(n + 1): is_equal_bit.add(n, 1) else: _, L, R = map(int, query.split()) eq_cnt = is_equal_bit.get_sum(R - 1) - is_equal_bit.get_sum(L - 1) print(R - L + 1 - eq_cnt)