#include<stdio.h>
#include<stdlib.h>

int main()
{
  int i,H;

  scanf("%d",&H);

  int a[H+1];

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

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

  return 0;
}

