#include <stdio.h>
#define M 2000000
#define INF -1
int N,S[M+1];
void MaxHeapify(int i){
  int left,right,lmax,tmp;
  left=2*i;
  right=2*i+1;
  if(left<=N && S[left]>S[i]) lmax=left;
  else lmax=i;
  if(right<=N && S[right]>S[lmax]) lmax=right;
  if(lmax!=i){
    tmp=S[i];
    S[i]=S[lmax];
    S[lmax]=tmp;
    MaxHeapify(lmax);
  }
}
int extractMax(){
  int maxvalue;
  if(N<1)return INF;
  maxvalue=S[1];
  S[1]=S[N--];
  MaxHeapify(1);
  return maxvalue;
}
void increaseKey(int i,int key){
  int tmp;
  if(key<S[i])return;
  S[i]=key;
  while(i>1 && S[i/2]<S[i]){
    tmp=S[i];
    S[i]=S[i/2];
    S[i/2]=tmp;
    i=i/2;
  }
}
void insert(int key){
  N++;
  S[N]=INF;
  increaseKey(N,key);
}
int main(){
  int key;
  char com[10];
  while(1){
    scanf("%s",com);
    if(com[0]=='e' && com[1]=='n') break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else printf("%d\n",extractMax());
  }
  return 0;
}