heap_size = gets.chomp.to_i

heap_tree = gets.chomp.split(" ")

heap_tree.each.with_index do |k, i|
  i_p = (i - 1) / 2
  i_l = 2 * i + 1
  i_r = 2 * i + 2

  print "node #{i+1}: key = #{k}, "

  print "parent key = #{heap_tree[i_p]}, " if i != 0
  print "left key = #{heap_tree[i_l]}, " if i_l <= heap_size - 1
  print "right key = #{heap_tree[i_r]}, " if i_r <= heap_size - 1
  puts
end