rt
#include <bits/stdc++.h>
using namespace std;
#define ll long long
set<int> l;
const int inf = 0x3f3f3f3f;
const ll INF = 0x7fffffff;
int main() {
//
int n;
cin >> n;
int leng;
set<int>::iterator check, f1, f2, f3;
l.insert(-inf);
l.insert(inf);
for (int i = 1; i <= n; i++) {
char p;
cin >> p;
if (p == '1') {
cin >> leng;
//check=l.find(leng);
if (l.find(leng) == l.end()) {
l.insert(leng);
continue;
} else {
cout << "Already Exist" << endl;
continue;
}
} else {
cin >> leng;
//check = l.find(leng);
if (l.size() <= 2) {
cout << "Empty" << endl;
continue;
} else if (l.find(leng) == l.end()) {
cout << leng << endl;
l.erase(leng);
//cout << l.find(leng);
continue;
} else {
f2 = l.find(leng);
f1 = l.find(leng)--;
f3 = l.find(leng)++;
if (*f2 - *f1 <= *f3 - *f2) {
cout << *f1 << endl;
l.erase(*f1);
continue;
} else {
cout << *f3 << endl;
l.erase(*f3);
continue;
}
l.erase(*f2);
}
}
}
return 0;
}
/*
in1:
7
1 1
1 5
1 3
2 3
2 3
2 3
2 3
out1:
3
1
5
Empty
*/