require 'priority_queue'
INF = 1 << 30
$pq = PriorityQueue.new
$n = 0

def extract
  p $pq
  INF - $pq.delete_min_return_priority
end

def insert key
  $pq.push($n ,INF - key)
  $n += 1
end

while l = gets
  break if l.chomp == "end"
  if l.chomp == "extract" then puts extract
  else insert(l.split[1].to_i)
  end
end