#include<bits/stdc++.h>
using namespace std;
int n,s,x;
set<int>a;
int main(){
cin>>n;
while(n--){
scanf("%d %d",&s,&x);
if(s==1){if(!a.insert(x).second)puts("Already Exist");}
else{
if(a.empty())puts("Empty");
else if(a.find(x)!=a.end()){
cout<<x<<'\n';
a.erase(a.find(x));
}
else{
set<int>::iterator r=a.lower_bound(x);
set<int>::iterator l=--r;++r;
if(r==a.end()){
cout<<*l<<'\n';
a.erase(l);
}
else if(r==a.begin()){
cout<<*r<<'\n';
a.erase(r);
}
else if(x-(*l)<=(*r)-x){
cout<<*l<<'\n';
a.erase(l);
}
else{
cout<<*r<<'\n';
a.erase(r);
}
}
}
}
return 0;
}