#include <stdio.h>
#define NIL -1
int main(){
  int N,H[1000]={NIL},i;
  scanf("%d",&N);
  for(i=1;i<=N;i++)
    scanf("%d",&H[i]);//key                                                     
  if(H[3]!=0)
    printf("node 1: key = %d, left key = %d, right key = %d, \n",H[1],H[2],H[3]\
);
  else if(H[2]!=0)
    printf("node 1: key = %d, left key = %d, \n",H[1],H[2]);
  else if(H[2]==0) printf("node 1: key = %d, \n",H[1]);

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


