#include <stdio.h>
#include <stdlib.h>

#define NIL 2000000000

typedef struct{
  int k; //key
  int lk; //left key
  int rk; //right key
}Node;

int main(){
  int k, h, i;
  Node *T;

  scanf("%d", &h);

  T = malloc((h + 1)*sizeof(Node));

  //initialize
  for(i = 1; i < h + 1; i++){
    T[i].k = NIL;
    T[i].lk = NIL;
    T[i].rk = NIL;
  }

  for(i = 1; i < h + 1; i++){
    scanf("%d", &k);

    T[i].k = k;

    if(i % 2 == 0) T[i/2].lk = k; //even number is left key;
    else T[i/2].rk = k; //odd number is right key;
  }

  //output
  for(i = 1; i < h + 1; i++){
    if(i == 1) printf("node 1: key = %d, left key = %d, right key = %d, \n", T[i].k, T[i].lk, T[i].rk);
    else{
      printf("node %d: key = %d, parent key = %d, ", i, T[i].k, T[i/2].k);

      if(T[i].lk != NIL) printf("left key = %d, ", T[i].lk);
      if(T[i].rk != NIL) printf("right key = %d, ", T[i].rk);

      printf("\n");
    }
  }

  return 0;
}