#include <stdio.h>


/*struct heap{
  int key;

  };*/
int main(){
  int H,i;

  scanf("%d",&H);
  int A[H+1];

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

  }


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


  return 0;
}