#include<stdio.h>
#include<stdlib.h>
#define Max 2000001

int A[Max];
int n = 0;

void Insert(int k){
  A[n] = k;
  n++;
}

int ExtractMax(void){
  int max = 0;
  int i;
  int j;
  int maxarray;
  for(i = 0;i < n;i++){
    if(max < A[i]){
      max = A[i];
      maxarray = i;
    }
  }
  for(j = maxarray;j < n;j++){
    A[j] = A[j+1];
  }
  n--;
  return max;
}

int main(){

  char command[10];
  int k;
  int i;

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

    if(command[0] == 'i'){
      scanf("%d",&k);
      Insert(k);
    }

    else if(command[1] == 'x'){
      printf("%d\n",ExtractMax());
      /*  for(i = 0;i < n;i++){
	printf("%d ",A[i]);
	printf("\n");
	}*/
    }

    else if(command[1] == 'n'){
      break;
    }
  }
  return 0;
}