import sys input = sys.stdin.readline N,Q=map(int,input().split()) A=list(map(int,input().split())) Query=[list(map(int,input().split())) for i in range(Q)] B=[A[i]-A[i-1] for i in range(1,N)]+[0] A=[0 if B[i]==0 else 1 for i in range(N)] # BIT(BIT-indexed tree) LEN=len(A)+1# 必要なら座標圧縮する BIT=[0]*LEN# 1-indexedなtree def update(v,w):# index vにwを加える while v<=LEN: BIT[v]+=w v+=(v&(-v))# 自分を含む大きなノードへ. たとえばv=3→v=4 def getvalue(v):# [1,v]の区間の和を求める ANS=0 while v!=0: ANS+=BIT[v] v-=(v&(-v))# 自分より小さい2ベキのノードへ. たとえばv=3→v=2へ return ANS for i in range(N-1): if B[i]!=0: update(i+1,1) for q in Query: if q[0]==1: i,l,r,x=q B[l-2]+=x B[r-1]-=x if A[l-2]==0 and B[l-2]!=0: A[l-2]=1 update(l-1,1) elif A[l-2]==1 and B[l-2]==0: A[l-2]=0 update(l-1,-1) if A[r-1]==0 and B[r-1]!=0: A[r-1]=1 update(r,1) elif A[r-1]==1 and B[r-1]==0: A[r-1]=0 update(r,-1) else: i,l,r=q print(getvalue(r-1)-getvalue(l-1)+1)