#include <stdio.h>
#include <string.h>
#include <limits.h>

#define MAX_H 514
#define INF INT_MAX 

int main(){
  int H,i,a[MAX_H],j;
  for(i = 0 ; i < MAX_H ; i++){
    a[i] = INF;
  }
  scanf("%d",&H);
  for(i = 0 ; i < H ; i++){
    scanf("%d",&a[i]);
  }
  for(i = 0 ; i < H ; i++){
    printf("node %d: key = %d, ", i+1, a[i]);
    if(i != 0){
      j = (i & 1 ? i/2 : (i-1)/2);
      printf("parent key = %d, ", a[j]);
    }
    if(a[i*2+1] != INF){
      printf("left key = %d, ", a[i*2+1]);
    }
    if(a[i*2+2] != INF){
      printf("right key = %d, ", a[i*2+2]);
    }
    printf("\n");
  }
  return 0;
}