#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
using namespace std;
set <int> a;
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
int op,l;
cin>>op>>l;
if(op==1)
{
if(a.count(l)>0)
cout<<"Already Exist"<<endl;
else
a.insert(l);
}
if(op==2)
{
if(a.empty())
{
cout<<"Empty"<<endl;
continue;
}
else if(a.count(l)>0)
{
cout<<l<<endl;
a.erase(l);
continue;
}
int x=*(--a.lower_bound(l));
int y=*a.upper_bound(l);
if(l-x<=y-l)
{
cout<<x<<endl;
a.erase(x);
continue;
}
else
{
cout<<y<<endl;
a.erase(y);
continue;
}
}
}
return 0;
}