#include<stdio.h>

int H[250];

int main(){

  int n,i;

  for(i=0; i<250; i++)
    H[i] = NULL;

  scanf("%d",&n);

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

  for(i=0; i<n; i++){

    printf("node %d: key = %d, ",i+1,H[i]);
    if((i+1)/2 >= 1)
      printf("parent key = %d, ",H[(i+1)/2-1]);
    if(H[(i+1)*2-1] != NULL)
      printf("left key = %d, ",H[(i+1)*2-1]); 
    if(H[((i+1)*2)] != NULL)
      printf("right key = %d, ",H[((i+1)*2)]);
    printf("\n");
  }

  return 0;
}