#include<stdio.h>
#define H 251


typedef struct{
  int key;
  int p;
  int dep;
  int left;
  int right;
}Node;

Node T[H];

int main(){

  int h,i;

  scanf("%d",&h);

  for(i=1;i<=h;i++){
    T[i].p=2000000001;
    T[i].left=2000000001;
    T[i].right=2000000001;
  }

  for(i=1;i<=h;i++){
    scanf("%d",&T[i].key);
  }

  
 for(i=1;i<=h;i++){
   if(i!=1)T[i].p = T[i/2].key;

   if(2*i<=h) T[i].left=T[2*i].key;
 
   if(2*i+1<=h) T[i].right=T[2*i+1].key;
  }

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,T[i].key);
  
    if(i!=1) printf("parent key = %d, ",T[i].p);

    if(T[i].left!=2000000001) printf("left key = %d, ",T[i].left);
    
    if(T[i].right!=2000000001) printf("right key = %d, ",T[i].right); 

    printf("\n");
  }

  return 0;
}

 
   
    