#include <iostream>
#include <math.h>
#include <set>
using namespace std;
set<int> s;
void Y(int x)
{
cout << x << endl;
s.erase(x);
}
int main() {
int q;
cin >> q;
while(q--)
{
int op, x;
cin >> op >> x;
if (op == 1)
{
if (s.find(x) == s.end()) s.insert(x);
else cout << "Already Exist" << endl;
}
else
{
if (s.empty()) cout << "Empty" << endl;
else if (x < *s.begin()) Y(*s.begin());
else if (x > *s.rbegin()) Y(*s.rbegin());
else
{
auto lb = s.lower_bound(x);
if (*lb == x)
{
Y(x);
continue;
}
else lb--;
auto ub = s.upper_bound(x);
if (x - *lb <= *ub - x) Y(*lb);
else Y(*ub);
}
}
}
return 0;
}
// 64 位输出请用 printf("%lld")