#include<stdio.h>

int main(){
  int H,i,parentkey,leftkey,rightkey;
  scanf("%d",&H);
  int A[H];
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=H;i++){
    if(i==1){
      leftkey=A[left(i)];
      rightkey=A[right(i)];
      printf("node %d: key = %d, left key = %d, right key = %d, \n",i,A[i],leftkey,rightkey);
    }
    else {
      parentkey=parent(i);
      leftkey=left(i);
      rightkey=right(i);
      if(leftkey<H){
	printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,A[i],A[parentkey],A[leftkey],A[rightkey]);
      }
      else if(leftkey==H){
	printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,A[i],A[parentkey],A[leftkey]);
      }
      else
	  printf("node %d: key = %d, parent key = %d, \n",i,A[i],A[parentkey]);
    }
  }

  return 0;
}

parent(i){
  return i/2;
}

left(i){
  return 2*i;
}

right(i){
  return 2*i+1;
}

