#include<stdio.h>
#define H 251
#define N 2000000001
typedef struct{
  int key;
  int p;
  int dep;
  int l;
  int r;
}Tree;
 
Tree T[H];
 
int main(){
  int h,i;
 
  scanf("%d",&h);
 
  for(i=1;i<=h;i++) T[i].p=T[i].l=T[i].r=N;
  
  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].l=T[2*i].key;  
   if(2*i+1<=h) T[i].r=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].l!=N) printf("left key = %d, ",T[i].l);
    if(T[i].r!=N) printf("right key = %d, ",T[i].r);  
    printf("\n");
  } 
  return 0;
}
 
  