#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL -1
#define N 500001

int n = 0, A[N];

void buildMaxHeap();
void maxHeapify(int);
void heapIncreaseKey(int n, int key);


void init(){
  int i;
  for(i = 0; i < N; i++){
    A[i] = NIL;
  }
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
   return 2*i+1;
}

void maxHeapInsert(int key){
  n = n + 1;
  A[n] = -10000000000000;
  heapIncreaseKey(n, key);
}

void heapIncreaseKey(int i, int key){
  int temp, p;
  
if (key < A[i]){
    printf("error\n");
  }
  
  p = parent(i);
  A[i] = key;

  while(i > 1 && A[p] < A[i]){
    temp = A[i];
    A[i] = A[p];
    A[p] = temp;
    i = p;
  }

}


int heapExtractMax(){
  int max;
  
  if(n < 1){
    return -11111111111111111;
  }
  
  max = A[1];
  A[1] = A[n];
  n = n - 1;
  maxHeapify(1);
  return max;
  
}


void maxHeapify(int i){
  int l, r, largest, temp;
  l = left(i);
  r = right(i);
  
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  
  if(r <= n && A[r] > A[largest]){
    largest = r;
  }
  
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(largest);
  }
  
}

int main(){
  
  int i, x;
  char com[20];
  init();

  while(1){
    scanf("%s ", com);
    if (strcmp(com,"insert") == 0){
      scanf("%d", &x);
      maxHeapInsert(x);
    } else if (strcmp(com,"extract") == 0){
      heapExtractMax();
    } else if (strcmp(com,"end") == 0){
      break;
    }
  }
  
  for(i = 1; i <= n; i++){
    printf("%d\n", A[i]);
  }
  
  return 0;

}