#include <stdio.h>

typedef struct{
  int key;
  int parent;
  int left;
  int right;
}node;

main(){
  int i,g;
  node N[250];
  scanf("%d",&g);
  for(i=0;i<g;i++){
    scanf("%d",&N[i].key);
    N[i].parent = 0;
    N[i].left = 0;
    N[i].right = 0;
  }
  for(i=1;i<=g;i++){
    if(i>1)N[i-1].parent = N[i/2-1].key;
    if((i*2)<=g)N[i-1].left = N[i*2-1].key;
    if((i*2+1)<=g)N[i-1].right = N[i*2].key;
  }

  for(i=0;i<g;i++){
    printf("node %d:key = %d,",i+1,N[i].key);
    if(N[i].parent!=0)printf(" parent key = %d,",N[i].parent);
    if(N[i].left!=0)printf(" left key = %d,",N[i].left);
    if(N[i].right!=0)printf(" right key = %d,",N[i].right);
    if(i<g-1)printf("\n");
  }
return 0;
}