#include <stdio.h>

#define MAX 10000

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

int main()
{
  int H,i,a[MAX+1];

  scanf("%d",&H);

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

  for(i=0;i<H;i++){
    printf("node %d: ",i+1);
    printf("key = %d, ",a[i+1]);
    if(parent(i+1) >= 1) printf("parent key = %d, ",a[parent(i+1)]);
    if(left(i+1) <= H) printf("left key = %d, ",a[left(i+1)]);
    if(right(i+1) <= H) printf("right key = %d, ",a[right(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;
}

