import scala.io.StdIn.{readLine,readInt}
import scala.collection.mutable.ArrayBuffer

object Main {

  def main(args: Array[String]) = {
    val n = readInt
    val heap = readLine.split(" ").map(_.toLong)
    val b = new ArrayBuffer[String]

    for(i<-1 to n) {
      val parent = if(i==1) "" else ", parent key = " + heap(i/2-1)
      val lr = if(2*i<n) ", left key = " + heap(2*i-1) + ", right key = " + heap(2*i) else ""
      b += "node " + (i) + ": key = " + heap(i-1)  + parent + lr
    }
    println(b.mkString("\n"))
  }
}