#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
int n; set<int>s;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; i++) {
int op, len;
cin >> op >> len;
if (op == 1) {
int z = s.size();
s.insert(len);
if (s.size() == z) {
cout << "Already Exist" << endl;
}
}
else {
if (s.empty()) {
cout << "Empty" << endl;
}
else if (s.size() == 1) {
cout << *s.begin() << endl;
s.erase(s.begin());
}
else {
int z = s.size();
s.erase(len);
if (z == s.size()) {
auto w = s.upper_bound(len);
if (w == s.end()) {
w--;
cout << *w << endl;
s.erase(*w);
}
else {
int xx = *w; w--;
int yy = *w;
s.erase(abs(yy - len) <= abs(xx - len) ? yy : xx);
cout << (abs(yy - len) <= abs(xx - len) ? yy : xx) << endl;
}
continue;
}
cout << len << endl;
}
}
}
return 0;
}