#include<bits/stdc++.h>
using namespace std;
int n;
set <int> pp;
set<int>::iterator it,t;
int main(){
cin >> n;
for (int i=0;i<n;i++){
int a,b;
cin >> a >> b;
if (a==1){
t=pp.find(b);
if (*t==b)
cout << "Already Exist" << endl;
else
pp.insert(b);
}
else{
if (pp.empty()){
cout << "Empty" << endl;
}
else{
it=pp.lower_bound(b);
if (*it==b){
cout << b << endl;
pp.erase(b);
}
else if (it==pp.end()){
int x;
x=*it;
cout << x << endl;
pp.erase(x);
}
else{
int x,y;
y=abs((*it--) -b);
x=abs(*it-b);
if (x<=y){
cout << *it << endl;
pp.erase(*it);
}
else{
cout << *++it << endl;
pp.erase(*it);
}
}
}
}
}
return 0;
}