/* 
* Complete Binaly Tree
* output 1)node_number, 2)parent_number, 3)depth, 4)kind_of_node, 5)child_list
*/

/* inclution */
#include <stdio.h>

/* definition */
#define HEAP_SIZE_MAX 250
#define VALUE_MAX 2000000
#define NIL -1

/* Prototype */
void printTree(int);
void getDepth(int, int);

///* Global Variables */
//struct Node {
//  int parent, left, right;
//};
//struct Node A[HEAP_SIZE]; //array for tree
//int n;

/* main */
int main(){
  int i, n, A[HEAP_SIZE_MAX];
  
  /* input the number of A[] */
  scanf("%d",&n);
  
  /* initialize array */
  for(i=1;i<=n;i++) { //??¨??????NIL??§?????????
    A[i] = NIL;
  }

  /* input array */
  for(i=1;i<=n;i++) {
    scanf("%d", &A[i]);
  }
  
  /* print */
  for(i=1;i<=n;i++) {
    printf("node %d: key = %d,", i, A[i]);
    /* parent */
    if(A[i/2] != 0) {
      printf("parent key = %d,", A[i/2]);
    }
    /* left */
    if(A[2*i] != 0) {
      printf("left key = %d,", A[2*i]);
    }
    if(A[2*i+1] != 0) {
      printf("right key = %d, ", A[2*i+1]);
    }
    printf("\n");
  }

  return 0;
}