#include<math.h>
#include<iostream>
#include<map>
using namespace std;
int n;
int m,longer,sum=0,maxx=0,minn=999999;
map<int,bool>box;
inline int read(){
char c=getchar();int x=0,f=1;
for(;!isdigit(c);c=getchar()){
if(c=='-'){
f=-1;
}
}
for(;isdigit(c);c=getchar()){
x=x*10+c-'0';
}
return x*f;
}
void store(int Length){
if(box[Length]){
cout<<"Already Exist"<<endl;
return ;
}
box[Length]=1;
sum++;
return ;
}
void print(int Length){
if(sum==0) cout<<"Empty"<<endl;
else if(box[Length]){
cout<<Length<<endl;
box[Length]=0;
sum--;
}
else{
int big=999999,small=0;
for(int i=minn;i<=maxx;i++){
if(i>Length&&box[i]==1) big=min(big,i);
if(i<Length&&box[i]==1) small=max(small,i);
}
if((big-Length)==(Length-small)){
cout<<small<<endl;
box[small]=0;
sum--;
}
else if((big-Length)>(Length-small)){
cout<<small<<endl;
box[small]=0;
sum--;
}
else{
cout<<big<<endl;
box[big]=0;
sum--;
}
}
return ;
}
int main(){
n=read();
while(n--){
m=read();
longer=read();
maxx=max(maxx,longer);
minn=min(minn,longer);
if(m==1) store(longer);
else print(longer);
}
}