/* * Author: Kewth * Date: echo -n ' ' && date +%Y.%m.%d # Type "!!sh" in Vim. * Solution: To be updated after "Accept". * Digression: * CopyRight: __ __ __ __ | |/ |.-----.--.--.--.| |_| |--. | < | -__| | | || _| | |__|\__||_____|________||____|__|__| */ #include #include #define debug(...) fprintf(stderr, __VA_ARGS__) typedef long long ll; static struct { inline operator int () { int x; return scanf("%d", &x), x; } /* inline operator ll () { ll x; return scanf("%lld", &x), x; } */ /* template inline void operator () (T &x) { x = *this; } */ /* template inline void operator () (T &x, A &...a) */ /* { x = *this; this -> operator () (a...); } */ } read; const int maxn = 5000005; bool a[maxn]; int main () { int n = read, q = n, first = 1, second = 2; while (q --) { int o = read, x = read; if (o == 1) { a[x] = 1; while (a[first] == 1) ++ first; while (second <= first or a[second] == 1) ++ second; } if (o == 2) printf("%d\n", x == first ? second : first); } }