class Node
  attr_accessor :id, :key, :parent, :left, :right

  def initialize(id, key)
    @id = id
    @key = key
    @parent = nil
    @left = nil
    @right = nil
  end

  def to_s
    parent_s =
      if @parent != nil
        "parent key = #{@parent.key}, "
      else
        ""
      end

    left_s =
      if @left != nil
        "left key = #{@left.key}, "
      else
        ""
      end

    right_s =
      if @right != nil
        "right key = #{@right.key}, "
      else
        ""
      end

    "node #{@id}: key = #{@key}, #{parent_s}#{left_s}#{right_s}"
  end
end

def left_p(i)
  2 * i
end
def right_p(i)
  2 * i + 1
end
def parent_p(i)
  i / 2
end


n = STDIN.gets.to_i
arr = STDIN.gets.split(' ')

tree = []
arr.each_with_index { |a, i|
  id = i + 1
  left_p = left_p(id)
  right_p = right_p(id)

  node = Node.new(id, a)

  if arr.size > left_p
    left = Node.new(left_p, arr[left_p - 1])
    left.parent = node
    node.left = left
  end
  if arr.size > right_p
    right = Node.new(right_p, arr[right_p - 1])
    right.parent = node
    node.right = right
  end
  node.parent = tree[parent_p(i+1) - 1]
  tree[i] = node
}

tree.each {|a|
  puts a
}