import sys input=sys.stdin.buffer.readline def Binit(B,siz): while len(B)siz+1: del B[-1] for i in range(siz+1): B[i]=0 B.append(siz) def Badd(B,a,x): z=a+1 while z<=B[-1]: B[z]+=x z+=(z&(-z)) def Bsum(B,a): r=0 z=a+1 while z>0: r+=B[z] z-=(z&(-z)) return r N,Q=map(int,input().split()) A=list(map(int,input().split())) C=[0]*(N+1) for i in range(N): C[i+1]=C[i]+A[i] X=0 B=[] Binit(B,N+1) for i in range(Q): t,l,r=map(int,input().split()) l-=1 if t==1: Badd(B,r+Bsum(B,r+X),r-l-1) X+=r-l-1 else: a,b=l+X,r+X a=Bsum(B,a) b=Bsum(B,b) #print(l+a,r+b,X) print(C[r+b]-C[l+a])