import scala.io.StdIn.{readInt, readLine};
object Main {
    def main(args: Array[String]): Unit = {
        val size = readInt + 1;
        val heap = new Array[Long](size);
        readLine.split(" ").zipWithIndex.foreach { v => heap(v._2 + 1) = v._1.toLong };
        dump(size, heap);
    }

    def dump(size: Int, heap: Array[Long]): Unit = {
        (1 until size).foreach { idx =>
            val parent = idx / 2;
            val left = idx * 2;
            val right = idx * 2 + 1;
            var msg = s"node ${idx}: key = ${heap(idx)}, ";
            if (parent > 0) msg += s"parent key = ${heap(parent)}, ";
            if (left < size) msg += s"left key = ${heap(left)}, ";
            if (right < size) msg += s"right key = ${heap(right)}, ";
            println(msg);
        }
    }
}
