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

int main(){
  int i, *T;
  int n;
  
  scanf("%d", &n);

  T= (int *) malloc ( sizeof(int) * (n+1) );
  
  for(i=1; i<=n; i++) scanf("%d", &T[i]);
  
  //出力 (output)
  for(i=1; i<=n; i++){
    printf("node %d: key = %d,",i,T[i]);
    if(i != 1) printf(" parent key = %d,",T[i/2]);
    if(i*2 <= n) printf(" left key = %d,",T[i*2]);
    if(i*2+1 <= n) printf(" right key = %d,",T[i*2+1]);
    printf(" \n");
  }
  
    return 0;
}

