#include <stdio.h>
#define MAX 250

int parent(int );
int left(int );
int right(int );

int main(void){

  int n,i;
  int Tree[MAX];

  scanf("%d",&n);

  for(i = 1; i <= n;i++)
    scanf("%d",&Tree[i]);
  
  for(i = 1;i <= n;i++){
    printf("node %d: key = %d, ", i, Tree[i]);

    if(parent(i) != 0)
      printf("parent key = %d, ", Tree[i/2]);

    if(left(i) <= n)
      printf("left key = %d, ", Tree[2 * i]);

    if(right(i)  <= n)
      printf("right key = %d, ", Tree[2 * i + 1]);

    printf("\n");
  }

  return 0;
}

int parent(int i){
  return i / 2;
}

int left(int i){
  return 2 * i;
}

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