#include using namespace std; typedef long long ll; typedef pair PII; const int N = 5e6 + 5, mod = 1e9 + 7; int n, a[N], fa[N], cnt[N], mx[N]; int find(int x) { if(x == fa[x]) return x; return fa[x] = find(fa[x]); } void merge(int x, int y) { x = find(x), y = find(y); if(x == y) return; if(cnt[x] < cnt[y]) { fa[x] = y; cnt[y] += cnt[x]; mx[y] = max(mx[x], mx[y]); } else { fa[y] = x; cnt[x] += cnt[y]; mx[x] = max(mx[x], mx[y]); } } int main() { //ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); scanf("%d", &n); for(int i = 1; i <= n; i++) { fa[i] = mx[i] = i; cnt[i] = 1; } int res = 0; for(int i = 0; i < n; i++) { int op, x; scanf("%d%d", &op, &x); if(op == 1) { if(a[x] == 1) continue; a[x] = 1; if(x == 1) res = max(res, 1); else if(a[x - 1] == 1) { merge(x - 1, x); if(res == x - 1) res = x; } if(a[x + 1] == 1) { merge(x, x + 1); if(res == x) res = mx[find(x)]; } } else { int ans = 0; if(res < x - 1) ans = res; else if(res == x - 1) { if(a[x + 1] == 1) ans = mx[find(x + 1)]; else ans = x; } else ans = res; printf("%d\n", ans + 1); } } return 0; }