#include #include #include #include using namespace std; using pii = pair; using vp = vector; int main() { int q; cin >> q; vp stk; int sz = 0; while (q--) { int op, x; cin >> op >> x; if (op == 1) { while (!stk.empty() && stk.back().second <= x) { stk.pop_back(); } stk.emplace_back(sz++, x); } else { cout << lower_bound(stk.begin(), stk.end(), pii(sz - x, -1))->second << endl; } } return 0; }