#include <stdio.h>

typedef struct node{
  int id,parent,left,right;
}point;

point array[10000000];

int main(){
  int H,i,p;
  
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&array[i].id);
    array[i].left = NULL;
    array[i].right = NULL;
    if(i%2==0){
      array[i].parent = array[i/2].id;
      array[i/2].left = array[i].id;
    }
    if(i%2==1){
      array[i].parent = array[i/2].id;
      array[i/2].right = array[i].id;
    }
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,array[i].id);
    if(i>=2)printf("parent key = %d, ",array[i].parent);
    if(array[i].left!=NULL)printf("left key = %d, ",array[i].left);
    if(array[i].right!=NULL)printf("right key = %d, ",array[i].right);
    printf("\n");
    }
  return 0;
}

