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|
  j = i + 1
  node = Node.new(j, a)
  left = Node.new(left_p(j), arr[left_p(j) - 1])
  left.parent = node
  right = Node.new(right_p(j) + 1, arr[right_p(j) - 1])
  right.parent = node
  node.left = left
  node.right = right
  node.parent = tree[parent_p(j) - 1]
  tree[i] = node
}

tree.each {|a|
  puts a
}