#include <stdio.h>

#define NIL -2

typedef struct{
  int id;
  int p;
  int l;
  int r;
} Node;

int main(){
  int n,i;

  scanf("%d",&n);

  Node node[n+1];

  for(i=1; i <= n; i++){
    node[i].p = node[i].l = node[i].r = NIL;
    scanf("%d",&node[i].id);
  }

  for(i=1; i <= n; i++){
    if(i != 1){
      node[i].p = node[i/2].id;
    }
    if(2*i <= n){
      node[i].l = node[2*i].id;
    }
    if(2*i+1 <= n){
      node[i].r = node[2*i+1].id;
    }
  }

  for(i=1; i <= n; i++){
    printf("node %d: key = %d, ",i,node[i].id);
    if(node[i].p != NIL){
      printf("parent key = %d, ",node[i].p);
    }
    if(node[i].l != NIL){
      printf("left key = %d, ",node[i].l);
    }
    if(node[i].r != NIL){
      printf("right key = %d, ",node[i].r);
    }
      printf("\n");
  }

  return 0;

}

