N,Q=tuple(map(int,input().split(' '))) a=list(map(int,input().split(' '))) ac=[False for i in range(len(a))] q=[] for i in range(Q): temp=input().split(" ") q.append([int(temp[0]),int(temp[1])-1]) for e in q: if e[0]==1: ac[e[1]]=True if e[0]==2: ac[e[1]]=False if e[0]==3: a[e[1]]+=1 if e[0]==4: A=0 # print(e[1],list(range(e[1],-1,-1))) for i in range(e[1]-1,-1,-1): if not ac[i]: break A+=a[i] for i in range(e[1],len(ac)-1,1): if not ac[i]: break A+=a[i+1] A+=a[e[1]] print(A)