#include<bits/stdc++.h>
using namespace std;
priority_queue<int,vector<int>,greater<int> > q;
int n;
int op,x;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n;
while(n--){
cin>>op;
if(op==1){
cin>>x;
q.push(x);
}else if(op==2){
cout<<q.top()<<"\n";
q.pop();
}else if(op==3){
q.pop();
}
}
return 0;
}
怎么了这是,为神魔部队