#include <stdio.h>
#include <string.h>

#define MAX 2000000

int A[MAX + 1], heap_size;

void maxHeapify(int i) {
    int l, tmp;
    if (i*2 <= heap_size && A[i*2] > A[i]) l = i*2;
    else l = i;
    if (i*2+1 <= heap_size && A[i*2+1] > A[l]) l = i*2+1;
    if (l != i) {
        tmp = A[i];
        A[i] = A[l];
        A[l] = tmp;
        maxHeapify(l);
    }
}

int heapMaximum() {
    return A[1];
}

void heapExtractMax() {
    int max = heapMaximum();
    printf("%d\n", max);
    A[1] = A[heap_size];
    heap_size--;
    maxHeapify(1);
    return;
}

void heapIncreaseKey(int k) {
    int i = heap_size, tmp;
    A[i] = k;
    while (i > 1 && A[i/2] < A[i]) {
        tmp = A[i];
        A[i] = A[i/2];
        A[i/2] = tmp;
        i /= 2;
    }
}

void maxHeapInsert(int k) {
    A[++heap_size] = -1;
    heapIncreaseKey(k);
}

int main(void){
    int n;
    char command[8];
    
    heap_size = 0;
    
    while (1) {
        scanf("%s", command);
        if (!strcmp("insert", command)) {
            scanf("%d", &n);
            maxHeapInsert(n);
            continue;
        }
        if (!strcmp("extract", command)) {
            heapExtractMax();
            continue;
        }
        break;
    }
    
    return 0;
}


