#include <stdio.h>

// void value(int *, int, int *);
int main(){
  int i;
  int A[250], n;
  scanf("%d", &n);
  for(i=1;i<=n;i++) scanf("%d", &A[i]);
  
  for(i=1;i<=n;i++){ // value(A, i, &A[i]);
    printf("node %d: key = %d,",i,A[i]);
    if(i != 1) printf(" parent key = %d,", A[i/2] );
    if(i/2<=n/2 && A[2*i]>0) printf(" left key = %d,",A[2*i]);
    if(i/2<=n/2 && A[2*i+1]>0) printf(" right key = %d,",A[2*i+1]);
    printf("\n");
  }
  return 0;
}

/*void value(int *p, int j, int *q){
 
  printf("node %d: key = %d,", j, *q);
  if(j != 1)printf(" parent key = %d,", p[j/2] );
  if(p[2*j] != '\0')printf(" left key = %d,", p[2*j] );
  if(p[2*j+1] != '\0')printf(" right key = %d,", p[2*j+1] );
  printf("\n");
  } */

