object Main extends App{
  val n: Int = io.StdIn.readInt
  val heap: Array[String] = io.StdIn.readLine().split(" ")

  for (i <- heap.indices) {
    val sb: StringBuilder = new StringBuilder
    val li: Int = i*2+1
    val ri: Int = i*2+2

    sb.append(s"node ${i+1}: key = ${heap(i)}, ")
    if (i != 0) {
      val pi: Int = (i-1)/2
      sb.append(s"parent key = ${heap(pi)}, ")
    }
    if (li < heap.length) {
      sb.append(s"left key = ${heap(li)}, ")
      if (ri < heap.length) sb.append(s"right key = ${heap(ri)}, ")
    }
    println(sb.result)
  }
}
