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

int parent(int i){
  if(i%2==0) return i/2;
  else return (i-1)/2;
}

int main(){
  int h,i;
  int *A;
  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) printf("parent key = %d,",A[parent(i)]);
    if(i*2<=h) printf(" left key = %d,",A[2*i]);
    if(2*i+1<=h) printf(" right key = %d,",A[2*i+1)]);
    printf("\n");
  }
  free(A);
  return 0;
}