#include<stdio.h>
#define MAX 2000001

//typedef unsigned long long llong;
int H;//dataの数stackのlastを示す値のように使っている
int S[MAX];

void swap(int *a,int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}


void increaseKey(int i,int k){
  if(k < S[i])return;
  S[i] = k;
  while(i>1 && S[i/2] < S[i]){
    swap(&S[i],&S[i/2]);
    i = i/2;
  }
}

void maxheap(int i){
  int left,right,largest;
  left = 2 * i;
  right = 2 * i + 1;
  if(left <= H && S[left] > S[i])largest = left;
  else largest = i;
  if(right <= H && S[right] > S[largest])largest = right;
  if(largest != i){
    swap(&S[i],&S[largest]);
    maxheap(largest);
  }
}



void insert(int k){
H++;
 S[H] = -1;
 increaseKey(H,k);
}

int extractMax(){
  int max;
  if(H < 1)return -1;
  max = S[1];//root
  S[1] = S[H--];
  maxheap(1);
  return max;
}

int main(){
  int key,temp;
  int datanum,i;
  char command[11];
  while(1){
    scanf("%s",command);
if(command[0] == 'e' && command[1] == 'n')break;
    if(command[0] == 'i'){
scanf("%d",&key);
insert(key);
}else if(command[0] == 'e' && command[1] == 'x'){
temp = extractMax();
 printf("%d\n",temp);
}
    else{
printf("command error\n");
}
  }
  return 0;
}

