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

void parent(int i){
  printf("parent key = ");
  if(i%2==0) printf("%d,",A[parent(i/2)]);
  else return printf("%d,",A[parent(i-1)/2]);
}
int left(int i){
  if(0<2*i && 2*i<=h) printf(" left key = %d,",A[left(2*i)]);
}
int right(int i){
   if(0<2*i+1 && 2*i+1<=h) printf(" right key = %d,"A[right(i*2+1)]);
}
int *A;
int main(){
  int h,i;
  scanf("%d",&h);
  A=(int *)malloc(h * sizeof(int));
  for(i=1;i<=h;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i!=1) parent(i);
    left(i);
    right(i)
    printf("\n");
  }
  free(A);
  return 0;
}