def parent(i)
  i / 2
end

def left(i)
  2 * i
end

def right(i)
  2 * i + 1
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i

  nodes = [nil] + gets.chomp.split.map(&:to_i)

  1.upto(n) do |i|
    key = nodes[i]

    output = "node #{i}: key = #{key}, "
    output << "parent key = #{nodes[parent(i)]}, " if parent(i) >= 1
    output << "left key = #{nodes[left(i)]}, " if left(i) <= n
    output << "right key = #{nodes[right(i)]}, " if right(i) <= n

    puts output
  end
end