import sys
import bisect
lst=list()
N =int(input())
for i in range(N):
    op,x = map(int,input().split())
    if op==1:
        idx = bisect.bisect_left(lst, x)
        #这样减少时间复杂度,若用not in 耗时太长
        if idx<len(lst) and lst[idx] == x:
            print("Already Exist")
        else:
            bisect.insort_left(lst,x)
    if op==2:
        if not lst:
            print("Empty")
        else:
            #idx(第一个大于等于x的位置)可能性
            #1.小于等于x一侧的最大值,下标为idx-1
            #2.大于等于x一侧的最小值,下标为idx
            idx=bisect.bisect_left(lst,x)
            if idx == 0:
                #x为最小的
                print(lst[idx])
                lst.pop(0)
            elif idx ==len(lst):
                #没有比x大的
                print(lst[idx-1])
                lst.pop(idx-1)
            else:
                #1,2情况同时存在
                #小于x的最大值
                c1 = lst[idx-1]
                #大于x的最小值
                c2 = lst[idx]

                if x-c1<=c2-x:
                    print(lst[idx-1])
                    lst.pop(idx-1)
                else :
                    print(lst[idx])
                    lst.pop(idx)