#include using namespace std; const int N = 5000005; int n, prv[N], nxt[N]; bool vis[N]; int main() { scanf("%d", &n); for (int t = 1; t <= n; t++) { int op, x; scanf("%d%d", &op, &x); if (op == 1) { if (!vis[x]) { vis[x] = 1; int L = x, R = x; if (vis[L - 1]) L = prv[L - 1]; if (vis[R + 1]) R = nxt[R + 1]; nxt[L] = R; prv[R] = L; } } else { int res; if (vis[x]) { if (vis[1]) res = nxt[1] + 1; else res = 1; } else { int L = x, R = x; if (vis[L - 1]) L = prv[L - 1]; if (vis[R + 1]) R = nxt[R + 1]; if (L == 1) res = R + 1; else { if (vis[1]) res = nxt[1] + 1; else res = 1; } } printf("%d\n", res); } } return 0; }