import numpy as np import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**8) N,Q=map(int,readline().split()) *a,=map(int,readline().split()) a = np.array([0]+a) def F(x,y): if x == y: return 1 else: return G(a[x],a[x+1])+F(x+1,y) def G(x,y): return x != y for i in range(Q): *q, = map(int,input().split()) if q[0]==1: a[q[1]:q[2]+1] += q[3] else: print(F(q[1],q[2]))