{Heapa,b;a.walloc(2d5);b.walloc(2d5);ll@q,@k;rep(q){ll@t;if(t<2)if(a.push(-rd_ll()),a.size==k)b.push(-a.pop());else wt(b.size?b.pop():-1);}}