from heapq import heapify, heappop,heappush N,M = map(int,input().split()) A = list(map(int,input().split())) hq = [] for i,a in enumerate(A): heappush(hq,(-a,-i-1)) num = [0]+A[:] q = int(input()) Q = [tuple(map(int,input().split()))for _ in range(q)] for t,x,y in Q: if t==1: num[x]+=y heappush(hq,(-num[x],-x)) elif t==2: num[x]-=y heappush(hq,(-num[x],-x)) else: while num[-hq[0][1]]!=-hq[0][0]: heappop(hq) print(-hq[0][1])