#include<stdio.h>
#define INTFY 10000000
#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest,swap;
  l=2*i;
  r=2*i+1;
  if(l<=H&&A[l]>A[i]){
    largest=l;
  }
  else{
    largest=i;
  }
  if(r<=H&&A[r]>A[largest]){
    largest=r;
  }
  if(largest!=i){
    swap=A[largest];
    A[largest]=A[i];
    A[i]=swap;
    maxHeapify(largest);
  }
}
int heapExactMax(){
  int max;
  if(H<1)return -INTFY;
  max=A[1];
  A[1]=A[H];
  H--;
  maxHeapify(1);

  return max;
}

void heapIncreaseKey(int i,int key){
  int chg;
  if(key<A[i])return;
  A[i]=key;
  while (i>1&&A[i/2]<A[i]) {
    chg=A[i];
    A[i]=A[i/2];
    A[i/2]=chg;
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INTFY;
  heapIncreaseKey(H,key);
}
int main(){
  int key;
  char com[10];

  while (1) {
    scanf("%s\n",com);
    if(com[0]=='e'&&com[1]=='n')break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else{
      printf("%d\n",heapExactMax());
    }
  }
  return  0;
}

