#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define rad M_PI/3
#define N 2000200
#define Max 10000
#define NTL -1
int n;
long heap[Max];

void Insert(long key){
  heap[n]=key;
 ++n;
}
long ExtraMax(){
  long max=0;
  long ch;
  long i;
  if(n<1)return -1;
  for(i=0;i<n;i++){
    if(max<heap[i]){
      max=heap[i];
      ch=i;
    }
  }
  heap[ch]=heap[n];
 return max;
 heap[n]=0;
  --n;
}
int main(){
  char op[1000];
  long val;
  while(1){
    scanf("%s",op);
    if(strcmp(op,"insert") == 0){
      scanf("%ld",&val);
      Insert(val);
    }
    else if(strcmp(op,"extract") == 0){
      printf("%ld\n",ExtraMax());
    }
    else if(strcmp(op,"end") == 0)break;
  }
  return 0;
}
