from heapq import heappop, heappush n,m = map(int,input().split()) A = list(map(int,input().split())) num = [0]+A[:] h = [] for i,a in enumerate(A): heappush(h,(-a,-i-1)) q = int(input()) Q = [list(map(int,input().split())) for i in range(q)] for t,x,y in Q: if t == 1: num[x] += y heappush(h,(-num[x],-x)) if t == 2: num[x] -= y heappush(h,(-num[x],-x)) if t == 3: while num[-h[0][1]] != -h[0][0]: heappop(h) print(-h[0][1])