#include<stdio.h>

#define INF 1000000
#define K 2000000

int n = 0;
int S[K];

void increase(int *S, int i, int key){
  int tmp;

  S[i] = key;

  while(i > 1 && S[i/2] < S[i]){
    tmp = S[i];
    S[i] = S[i/2];
    S[i/2] = tmp;
    i = i/2;
  }
}

void insert(int *S, int k){
  n += 1;
  S[n] = -INF;
  increase(S, n, k);
}

void maxHeapify(int *S, int i){
  int l, r, tmp, largest;

  l = 2*i;
  r = 2*i + 1;

  if(l <= n && S[l] > S[i]) largest = l;
  else largest = i;

  if(r <= n && S[r] > S[largest]) largest = r;

  if(largest != i){
    tmp = S[i];
    S[i] = S[largest];
    S[largest] = tmp;
    maxHeapify(S, largest);
  }
}

int extractMax(int *S){
  int max;

  max = S[1];
  S[1] = S[n];
  n--;
  maxHeapify(S, 1);

  return max;
}

int main(){
  int i=0, k, j, max[K];
  char chil[10];

  while(1){
    scanf("%s", chil);

    if(chil[0] == 'i'){
      scanf("%d", &k);
      insert(S, k);
    }

    else if(chil[1] == 'x'){
      max[i] = extractMax(S);
      i++;
    }
    else if(chil[1] == 'n') break;
  }

  for(j = 0; j < i; j++) printf("%d\n", max[j]);

  return 0;
}