#include<stdio.h>

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