#include<bits/stdc++.h>
using namespace std;
int main()
{
set<int>s;
int n;
cin>>n;
while(n--)
{
int k,x;
cin>>k>>x;
if(sk==1)
{
if(s.find(x)==s.end())
s.insert(x);
else cout<<"Already Exist"<<endl;
}
else if(k==2)
{
if(s.empty()) cout<<"Empty"<<endl;
else
{
set<int>::iterator l=s.lower_bound(k),r=s.upper_bound(k);
if(l!=s.begin())l--;
if(abs(*l-x)>abs(*r-x))
{
cout<<*r<<endl;
s.erase(r);
}
else
{
cout<<*l<<endl;
s.erase(l);
}
}
}
}
}