#include<iostream>
using namespace std;
int heap[100005],q,n;
void put(){
int x=n;
while(x>1){
int temp=x/2;
if(heap[temp]>heap[x])
swap(heap[temp],heap[x]);
else
return;
x=temp;
}
return;
}
void del(){
int x=1;
while(x<=n){
int temp=x*2;
if(heap[temp+1]<heap[temp])
temp++;
if(heap[temp]<heap[x])
swap(heap[temp],heap[x]);
else
return;
x=temp;
}
return;
}
int main(){
cin>>q;
while(q--){
int t,a;
cin>>t;
if(t==1){
cin>>a;
heap[n+1]=a;
n++;
put();
}
if(t==2){
cout<<heap[1]<<endl;
}
if(t==3){
heap[1]=heap[n];
n--;
del();
}
}
return 0;
}
如能发现并告知。感激不尽。