import scala.io.StdIn.{readInt, readLine}

object Main extends App {

  class Node {
    var id: Int = 0
    var key: Int = 0
    var parent: Node = null
    var left: Node = null
    var right: Node = null
    override def toString: String = {
      val sb = new StringBuilder(s"node ${id}: key = ${key}, ")
      if (parent != null) sb.append(s"parent key = ${parent.key}, ")
      if (left != null) sb.append(s"left key = ${left.key}, ")
      if (right != null) sb.append(s"right key = ${right.key}, ")
      sb.toString
    }
  }

  val n = readInt
  val arr = readLine.split(" ").map(_.toInt)

  val nodes = Array.fill[Node](n)(new Node)
  for (i <- 0 until n) {
    val id = i + 1
    nodes(i).id = id
    nodes(i).key = arr(i)
    var parentId = -1
    if (id % 2 == 0)  parentId = id / 2
    else parentId = (id - 1) / 2
    if (parentId >= 1 && parentId <= n) nodes(i).parent = nodes(parentId - 1)
    val leftId = id * 2
    val rightId = leftId + 1
    if (leftId <= n) nodes(i).left = nodes(leftId - 1)
    if (rightId <= n) nodes(i).right = nodes(rightId - 1)
  }

  for (i <- 0 until n) {
    println(nodes(i))
  }
}

