#include<stdio.h>

int main(){

  int h,A[251],i,j;

  scanf("%d",&h);

  
  for(i=1;i<=h;i++){

    scanf("%d",&A[i]);

  }

  for(j=1;j<=h;j++){

    if(j==1){
      printf("node %d: key = %d, left key = %d, right key = %d,\n",j,A[j],A[2*j],A[2*j+1]);
    }
    else if(2*j+1<=h){
      printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d,\n",j,A[j],A[j/2],A[2*j],A[2*j+1]);
    }
    else if(2*j<=h){
      printf("node %d: key = %d, parent key = %d, left key = %d,\n",j,A[j],A[j/2],A[2*j]);
    }
    else printf("node %d: key = %d, parent key = %d,\n",j,A[j],A[j/2]);

  }
  return 0;
}