def pq()
  q = []
  a = []
  loop{
    a = gets.split(' ')
    if a[0] == 'insert'
      n = a[1].to_i
      q.push(n)
    elsif a[0] == 'extract'
      puts q.max
      q.delete_at(q.index(q.max))
    elsif a[0] == 'end'
      break
    end
  }
end

pq()