#include <stdio.h>
#define H 500
 
int A[H],n;
 
int main(void){
 
  int k,p,l,r,i;
 
  scanf("%d",&n);
 
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
 
  for(i=1;i<=n;i++){
    k = A[i];
    p = A[i/2];
    l = A[2*i];
    r = A[(2*i)+1];
 
    printf("node %d: key = %d, ",i,k);
    if(p!=0 && i != 1) printf("parent key = %d, ",p);
    if(l!=0) printf("left key = %d, ",l);
    else{
      printf("\n");
      continue;
    }
    if(r!=0)  printf("right key = %d, ",r);
    printf("\n");
  }
  return 0;
}