n = gets.to_i
heep = gets.split.map(&:to_i)

heep.each_with_index{|val, j|
  i = j + 1
  str = "node #{j}: key = #{val}, "
  str << "parent key = #{heep[i/2-1]}, " if j > 0
  str << "left key = #{heep[2*i-1]}, " if 2 * i - 1 < n
  str << "right key = #{heep[2*i]}, " if 2 * i < n
  puts str
}