#include<stdio.h>

int n,a[2000001];

void maxheap(int x){
  
  int y,l,r,max;
  l = 2 * x;
  r = 2 * x+1;

  if(l<=n && a[l] > a[x]) max = l;
  else max = x;

  if(r<=n && a[r] > a[max]) max = r;

  if(max != x){
    y = a[x];
    a[x] = a[max];
    a[max] = y;
    maxheap(max);
  }
}

int extr(){
  int max;
  if(n<1) return -1;
  max = a[1];
  a[1] = a[n--];
  maxheap(1);
  return max;
}

void inckey(int x,int key){

  int b;
  if(key<a[x]) return;
  a[x] = key;
  while(x>1 && a[x/2] < a[x]){
    b = a[x];
    a[x] = a[x/2];
    a[x/2] = b;
    x = x/2;
  }
}

void insert(int key){
  n++;
  a[n] = -1;
  inckey(n,key);
}

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

