#include<stdio.h>
int array[1000];
int number;


void hyouzi(int i){

  printf("node %d: key = %d, ",i,array[i]);
  if(parent(i)>=1){printf("parent key = %d, ",array[parent(i)]);}
  if(left(i)<=number){printf("left key = %d, ",array[left(i)]);}
  if(right(i)<=number){printf("right key = %d, ",array[right(i)]);}

      printf("\n");
}




int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}


int main(){

  
  scanf("%d",&number);


  
  int i;
  for(i=1;i<=number;i++){
    scanf("%d",&array[i]);
    }


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

    hyouzi(i);
  }


  

  return 0;
}

