#include <iostream>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

int main() {
    set<int> s;
    int q;
    cin >> q;
    while (q--) {
        int option;
        cin >> option;
        int x;
        cin >> x;
        switch (option) {
            case 1:
                if (s.count(x) == 1) {
                    cout << "Already Exist" << endl;
                } else if (s.count(x) == 0) {
                    s.insert(x);
                }
                break;
            case 2:
                if (s.empty()) {
                    cout << "Empty" << endl;

                } else {
                    auto it=s.lower_bound(x);
                    int tmp1=INT_MAX,tmp2=INT_MAX;

                    if(it!=s.end())
                    {
                        tmp1=*it;
                    }

                    if(it!=s.begin())
                    {
                        auto prev_it=it;
                        prev_it--;
                        tmp2=*prev_it;
                    }

                    int result=0;

                    if(tmp1==INT_MAX)
                    {
                        result=tmp2;
                    }
                    else if (tmp2==INT_MAX) {
                        result=tmp1;
                    }
                    else {
                        int diff1=abs(tmp1-x);
                        int diff2=abs(tmp2-x);

                        if(diff1<diff2)
                        {
                            result=tmp1;
                        }
                        else if (diff1>diff2) {
                            result=tmp2;
                        }
                        else {
                            result=min(tmp1,tmp2);
                        }
                    }
                    
                    cout<<result<<endl;
                    s.erase(result);
                }
                break;
        }
    }
    return 0;
}