#include <stdio.h>
#include <math.h>
#define N 250

main(){
  int n,i,*k[N],x;

  scanf("%d",&n);

  for(i=1; i<=n; i++){
    scanf("%d",(k+i));
  }


  for(i=1; i<=n; i++){

    printf("node %d:",i);
    printf("key = %d, ",*(k+i));

    if(i==1){
      printf("left key = %d, ",*(k+2*i));
      printf("right key = %d,\n",*(k+(2*i+1)));
    }
    

    else if(i!=1 && 2*i+1<=n){
      x=floor(i/2);
      printf("parent key = %d, ",*(k+x));
      printf("left key = %d, ",*(k+2*i));
      printf("right key = %d,\n",*(k+(2*i+1)));
    }
    else if(i!=1 && 2*i<=n){
  x=floor(i/2);
      printf("parent key = %d, ",*(k+x));
      printf("left key = %d\n, ",*(k+2*i));
    }
    else{
      x=floor(i/2);
      printf("parent key = %d,\n",*(k+x));
    }
  }
  return 0;
}