#include<bits/stdc++.h>
using namespace std;
multiset<int> st;
multiset<int>::iterator it,jt;
int main(){
int m;
cin>>m;
int a,b;
while(m--){
cin>>a>>b;
if (a==1){
it=st.find(b);
if (it!=st.end()){
cout<<"Already Exist"<<endl;
}
else {st.insert(b);}
}
else if(a==2){
if (st.empty()){
cout<<"Empty"<<endl;
continue;
}
it=st.find(b);
if (it!=st.end()){
cout<<*it<<endl;
st.erase(it);
}
else {
it=st.lower_bound(b);
jt=st.upper_bound(b);
if (it!=st.begin()){
cout<<*(--it)<<endl;
st.erase(it);
}
else if (jt!=st.end()){
cout<<*jt<<endl;
st.erase(jt);
}
}
}
}
}