n = gets.chomp.to_i
nodes = gets.chomp.split(' ').map(&:to_i)
nodes.each_with_index do |node, i|
  parent_i = (i + 1) / 2 - 1
  left_child_i = (i + 1) * 2 - 1
  right_child_i = (i + 1) * 2
  parent_k = (parent_i >= 0 && parent_i <= n - 1) ? nodes[parent_i] : nil
  left_child_k = (left_child_i >= 0 && left_child_i <= n - 1) ? nodes[left_child_i] : nil
  right_child_k = (right_child_i >= 0 && right_child_i <= n - 1) ? nodes[right_child_i] : nil
  s =  "node #{i + 1}: key = #{node}, "
  s += "parent key = #{parent_k}, " if parent_k
  s += "left key = #{left_child_k}, " if left_child_k
  s += "right key = #{right_child_k}, " if right_child_k
  puts s
end
