from sys import stdin def input(): return stdin.readline().rstrip("\n") n, k, qc = map(lambda s_: int(s_), input().split()) a = tuple(map(lambda s_: int(s_), input().split())) from heapq import heappop, heappush q_large = [] q_small = [] def push(x): heappush(q_small, -x) while len(q_small) > k: x = heappop(q_small) x = -x heappush(q_large, x) def pop_k(): x = heappop(q_small) x = -x while len(q_small) < k: nx = heappop(q_large) heappush(q_small, -nx) return x for ai in a: push(ai) for _ in range(qc): ty, *rem = map(lambda s_: int(s_), input().split()) if ty == 1: x, = rem push(x) if ty == 2: y, = rem x = pop_k() push(x + y) if ty == 3: print(-q_small[0])