#include #include #include #include #include using namespace std; const int maxn = 10000010, inf = 1e9 + 233; int tr[maxn], a[maxn]; int ty, x, n; template inline void read(T &k) { int f = 1; k = 0; char c = getchar(); while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar(); while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar(); k *= f; } inline void add(int x, int delta) {for (; x <= n; x += x & -x) tr[x] += delta;} void query() { int ans = 0; for (int i = log2(n); ~i; i--) if (ans + (1 << i) <= n) if (tr[ans + (1 << i)] == (1 << i)) ans += 1 << i; printf("%d\n", ans + 1); } void solve() { read(n); for (int i = 1; i <= n; i++) { read(ty); read(x); if (ty == 1) { if (!a[x]) a[x] = 1, add(x, 1); } else { if (!a[x]) add(x, 1); query(); if (!a[x]) add(x, -1); } } } int main() { int T = 1; while (T--) solve(); }