#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int n, k, x;
map<int, int> a;
int main() {
cin >> n;
while (n--) {
cin >> k >> x;
if (k == 1) {
if (a.count(x))cout << "Already Exist" << endl;
else a[x] = 1;
}
else {
if (a.empty())cout << "Empty" << endl;
else if (a.count(x)) {
cout << x << endl;
a.erase(x);
}
else {
a[x] = 1;
map<int, int>::iterator it1, it2;
it1 = a.find(x);
it2 = it1;
it1++;
if (it2 == a.begin())cout << it1->first << endl, a.erase(it1);
else if (it1 == a.end())cout << (it2--)->first << endl, a.erase(it2--);
else if (x - (--it2)->first > it1->first - x) {
cout << it1->first << endl;
a.erase(it1);
}
else {
cout << it2->first << endl;
a.erase(it2);
}
a.erase(x);
}
}
}
return 0;
}