#include <stdio.h>
#include <string.h>
#define MAX 1500000
#define N -100000
   
int size = 1;
 
int parent(int i) {
  return i/2;
}
int left(int i) {
  return 2*i;
}
int right(int i) {
  return 2*i + 1;
}
   
void mheapi(int *A, int i) {
  int l = left(i);
  int r = right(i);
  int lar;
   
  if (l <= size && A[l] > A[i]) {
    lar = l;
  } else {
    lar = i;
  }
  if (r <= size && A[r] > A[lar]) {
    lar = r;
  }
   
  if (lar != i) {
    r = A[lar];
    A[lar] = A[i];
    A[i] = r;
   
    mheapi(A, lar);
  }
}
   
void heapkey(int *A, int i, int key) {
  if (key < A[i]) {
    return;
  }
   
  A[i] = key;
  while (i > 1 && A[parent(i)] < A[i]) {
    key = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = key;
    i = parent(i);
  }
}
     
void ins(int *A, int key) {
  size++;
  A[size] = N;
  heapkey(A, size, key);
}
 
int getM(int *A) {
  if (size < 1) {          
    return -1;
  }
   
  int m = A[1];
  A[1] = A[size];
  size--;
  mheapi(A, 1);
  return m;
}
int main(void) {
  int key;
  int ary[MAX];
  char order[10];
  int m;
   
  while (1) {
    scanf("%s %d", order, &key);
    if (order[0] == 'i') {
      ins(ary, key);
    } else if (order[1] == 'x') {
      m = getM(ary);
      printf("%d\n", m);
    } else {
      break;
    }
  }
  return 0;
}