class Node
  attr_accessor :key, :parent, :left, :right
  def initialize(key)
    @key = key
  end
end

n = gets.to_i
heap = []
gets.split.map(&:to_i).each{ |i| heap << Node.new(i) }
heap.unshift nil
(1..n).each do |i| 
  heap[i].parent = heap[i/2] if i > 0 
  heap[i].left = heap[2*i] if n >= 2*i
  heap[i].right = heap[2*i+1] if n >= 2*i+1
end
(1..n).each do |i|
 print "node #{i}:, key = #{heap[i].key},"
 print " parent key = #{heap[i].parent.key}," if heap[i].parent
 print " left key = #{heap[i].left.key}," if heap[i].left
 print " right key = #{heap[i].right.key}," if heap[i].right
 puts
end