#include <stdio.h>
#define M 10001
#define NIL M+1

int main(void){
  int i,x[M],limit,left,right,parent;
  for(i=0;i<=M;i++){
    x[i]= NIL;
  }
  
  scanf("%d",&limit);
  for(i=1;i<=limit;i++){
    scanf("%d",&x[i]);
  }
  for(i=1;i<=limit;i++){
    printf("node %d: ",i);
    printf("key = %d, ",x[i]);
    parent = x[i/2];
    left = x[2 * i];
    right = x[2*i +1];
    if(parent != NIL){
      printf("parent key = %d, ",parent);
    }
    if(left != NIL){
      printf("left key = %d, ",left);
    }
    if(right != NIL){
      printf("right key = %d, ",right);
    }
    printf("\n");
  }
  return 0;
}

