class BIT: def __init__(self, n): self.n = n self.bit = [0]*(self.n+1) # 1-indexed def init(self, init_val): for i, v in enumerate(init_val): self.add(i, v) def add(self, i, x): # i: 0-indexed i += 1 # to 1-indexed while i <= self.n: self.bit[i] += x i += (i & -i) def sum(self, i, j): # return sum of [i, j) # i, j: 0-indexed return self._sum(j) - self._sum(i) def _sum(self, i): # return sum of [0, i) # i: 0-indexed res = 0 while i > 0: res += self.bit[i] i -= i & (-i) return res def __str__(self): # for debug arr = [self.sum(i,i+1) for i in range(self.n)] return str(arr) class RangeAddBIT: def __init__(self, n): self.n = n self.bit1 = BIT(n) self.bit2 = BIT(n) def init(self, init_val): self.bit2.init(init_val) def add(self, l, r, x): # add x to [l, r) # l, r: 0-indexed self.bit1.add(l, x) self.bit1.add(r, -x) self.bit2.add(l, -x*l) self.bit2.add(r, x*r) def sum(self, l, r): # return sum of [l, r) # l, r: 0-indexed return self._sum(r) - self._sum(l) def _sum(self, i): # return sum of [0, i) # i: 0-indexed return self.bit1._sum(i)*i + self.bit2._sum(i) def __str__(self): # for debug arr = [self.sum(i,i+1) for i in range(self.n)] return str(arr) import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n, q = map(int, input().split()) A = list(map(int, input().split())) B = [] for i in range(n-1): if A[i] == A[i+1]: B.append(0) else: B.append(1) bit1 = RangeAddBIT(n+1) bit1.init(A) bit2 = BIT(n+1) bit2.init(B) for i in range(q): temp = list(map(int, input().split())) #print(i, bit1) #print(i, bit2) if temp[0] == 1: l, r, x = temp[1:] l, r = l-1, r-1 bit1.add(l, r+1, x) if l != 0: if bit1.sum(l-1, l) != bit1.sum(l, l+1): bit2.add(l-1, -bit2.sum(l-1, l)) bit2.add(l-1, 1) else: bit2.add(l-1, -bit2.sum(l-1, l)) bit2.add(l-1, 0) if r != n-1: if bit1.sum(r, r+1) != bit1.sum(r+1, r+2): bit2.add(r, -bit2.sum(r, r+1)) bit2.add(r, 1) else: bit2.add(r, -bit2.sum(r, r+1)) bit2.add(r, 0) else: l, r = temp[1:] l, r = l-1, r-1 ans = bit2.sum(l, r)+1 print(ans)