import sys

from heapq import heappush,heappop

H=[]

O=[]

for e in sys.stdin:

 if'i'==e[0]:heappush(H,-int(e[7:]))

 elif't'==e[2]:O+=[-heappop(H)]

 else:print(('\n'.join(map(str,O))))

import sys

from heapq import*

H=[]

O=[]

for e in sys.stdin:

 if'i'==e[0]:heappush(H,-int(e[7:]))

 elif't'==e[2]:O+=[-heappop(H)]

 else:print(('\n'.join(map(str,O))))

import sys
from heapq import heappush, heappop

H = []
O = []
for e in sys.stdin:
    if "i" == e[0]:
        heappush(H, -int(e[7:]))
    elif "t" == e[2]:
        O += [-heappop(H)]
    else:
        print(("\n".join(map(str, O))))

import sys
from heapq import *

H = []
O = []
for e in sys.stdin:
    if "i" == e[0]:
        heappush(H, -int(e[7:]))
    elif "t" == e[2]:
        O += [-heappop(H)]
    else:
        print(("\n".join(map(str, O))))

-from heapq import heappush, heappop +from heapq import *