U253992
#include<bits/stdc++.h>
using namespace std;
priority_queue<int,vector<int>,greater<int> >w;
int main()
{
long long n;
cin>>n;
char a;
long long b;
for(int i=1;i<=n;i++)
{
cin>>a;
if(a=='i')
{
cin>>b;
w.push(b);
}
else
{
cout<<w.top()<<"\n";
w.pop();
}
}
return 0;
}