#include<stdio.h>
#include<string.h>
long k[2000000];
int main(){
    int i, l=0;
    long tmp, xk;
    char op[7];
    while(1){
        scanf("%s", op);
        if(!strcmp(op, "insert")){
            scanf("%ld", &k[l++]);
            xk=k[l-1];
            for(i=l-2; i>=0; i--){
                if(k[i]>xk){
                    tmp=k[i+1];
                    k[i+1]=k[i];
                    k[i]=tmp;
                }else break;
            }
        }
        else if(!strcmp(op, "extract")){
            printf("%d\n", k[l-1]);
            l--;
        }else break;
    }
    return 0;
}