def main
  gets
  arr = gets.split(" ").map(&:to_i)
  def arr.[](n)
    super(n - 1)
  end
  arr.each_with_index{|item, idx|express(arr,idx + 1)}
end
def express(arr, idx)
  exp = ["node #{idx}: key = #{arr[idx]},"]
  exp << "parent key = #{arr[idx / 2]}," if idx != 1
  exp << "left key = #{arr[idx * 2]}," if idx * 2 <= arr.size
  exp << "right key = #{arr[idx * 2 + 1]}," if idx * 2 < arr.size
  puts exp.join(" ")
end
main