#include using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define ll long long const long long mod=998244353; const long long hmod=46216567629137; class SegmentTree{ public: int dat[800000],siz=1; SegmentTree(int N){ siz=1; while(siz=2){ pos/=2; dat[pos]=max(dat[pos*2],dat[pos*2+1]); } } int query(int l,int r,int a,int b,int u){ if(r<=a || b<=l) return -1000000000; if(l<=a && b<=r) return dat[u]; int m=(a+b)/2; int AnswerL=query(l,r,a,m,u*2); int AnswerR=query(l,r,m,b,u*2+1); return max(AnswerL,AnswerR); } }; int main(){ cin.tie(0)->sync_with_stdio(0); cout.tie(0); int Q; cin>>Q; int query[Q+1]; int x[Q+1],k[Q+1]; int siz=0; SegmentTree Z(Q); for(int i=1;i<=Q;i++){ cin>>query[i]; if(query[i]==1){ cin>>x[i]; siz++; Z.update(siz,x[i]); } if(query[i]==2){ cin>>k[i]; int ans=Z.query(siz-k[i]+1,siz+1,1,Z.siz+1,1); cout<