#include<stdio.h>
#define L 2000

int main(){

  int n,i,j,k,pk,lk,rk,h,id;
 int A[250];
  scanf("%d",&h);

  for(i=1;i<h+1;i++){
    scanf("%d",&A[i]);

  }
  for(i=1;i<h+1;i++){
    id = i;
    pk = i/2;
    lk = 2*i;
    rk = 2*i+1;
    
    if(i==1){
      if(h>=3) printf("node %d: key = %d, left key = %d, right key = %d, \n",id,A[i],A[2],A[3]);
      if(h==2)  printf("node %d: key = %d, left key = %d, \n",id,A[i],A[2]);
      if(h==1) printf("node %d: key = %d, \n",id,A[i]);
    }
    if(i==1)continue;
    
    printf("node %d: key = %d, parent key = %d, ",id,A[i],A[pk]);
      
    if(lk<=h&&rk<=h){
      printf("left key = %d, right key = %d, ",A[lk],A[rk]);
    }
    else if(lk<=h&&rk>h) printf("left key = %d, ",A[lk]);

    if(i!=h+1)printf("\n");
  }
  return 0;
}

