from bisect import bisect_left stidx = [] stval = [] now = 0 for _ in range(int(input())): t, x = map(int, input().split()) if t == 1: while stval and stval[-1] <= x: stval.pop() stidx.pop() stval.append(x) stidx.append(now) now += 1 else: i = bisect_left(stidx, now - x) print(stval[i])