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

int main(){
  int i,j,H,*z;

  scanf("%d",&H);
  z = malloc(H*sizeof(int)+1);
  for(i=1;i <= H;i++){
    scanf("%d",&z[i]);
  }
  for(i=1;i <= H;i++){
    printf("node %d: key = %d, ",i,z[i]);
    if(i/2 != 0){
      printf("parent key = %d, ",z[i/2]);
    }
    if(2*i <= H){
      printf("left key = %d, ",z[2*i]);
    }
    if(2*i+1 <= H){
      printf("right key = %d, ",z[2*i+1]);
    }
    printf("\n");
  }
  return 0;
}

