#include<stdio.h>

typedef struct{

  int key;
  int p;
  int l;
  int r;
}Node;


int main(){

  int n,i,k;

  scanf("%d",&n);

  Node N[n+1];


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

   N[i].key = N[i].p = N[i].l = N[i].r = -1;
   
 }
  for(i=1;i<=n;i++){

    scanf("%d",&k);

    N[i].key = k;

    if(i != 1){

      N[i].p = i/2;
    }

      if((2*i) <= n) N[i].l = 2*i;

      if(((2*i)+1) <= n) N[i].r = 2*i+1;
    
    

  }

 for(i=1;i<=n;i++){
   printf("node %d: ",i);
   printf("key = %d, ",N[i].key);
   if(N[i].p!=-1)
     printf("parent key = %d, ",N[N[i].p].key);
   if(N[i].l!=-1)
     printf("left key = %d, ",N[N[i].l].key);
    if(N[i].r!=-1)
     printf("right key = %d, ",N[N[i].r].key);
   
   printf("\n");
 }
 return 0;
}

