#include <stdio.h>
struct Tree{
  int k;
  int pk;
  int lk;
  int rk;
};
 
int main(){
 
  int H,i;
  struct Tree A[251];
  scanf("%d",&H);
 
  for(i=0;i<H;i++){
  scanf("%d",&A[i+1].k);
  }
 
   for(i=1;i<=H;i++){
    if(i/2 >0)    A[i].pk=A[i/2].k;
    // else A[i].pk=-1;
 
    if(2*i+1<=H && 2*i !=0){
      A[i].lk=A[2*i].k;
      A[i].rk=A[2*i+1].k;
    }
    /* else {
      A[i].lk=-1;
      A[i].rk=-1;
    }
    */
  }
   
  for(i=1;i<=H;i++){
    printf("node %d;key = %d,",i,A[i].k);
    if(A[i].pk>0)
      printf(" parent key = %d",A[i].pk);
 
    if(A[i].lk>0)    printf(" left key = %d,",A[i].lk);
 
    if(A[i].rk>0)  printf(" right key = %d,",A[i].rk);
     
    printf("\n");
  }
 
 
  return 0;
}