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

#define H 250

int main(){
  int h, i;
  int a[H];

  scanf("%d", &h);
  if(h > H) exit(1);

  for(i=0; i<h; i++){
    scanf("%d", &a[i]);
    if(a[i] < -2000000000 || a[i] > 2000000000) exit(2);
  }

  for(i=1; i<h+1; i++){
    printf("node %d: ", i);
    printf("key = %d, ", a[i-1]);
    if(i != 1) printf("parent key = %d, ", a[i/2-1]);
    if(i*2 < h+1) printf("left key = %d, ",a[i*2-1]);
    if(i*2+1 < h+1) printf("right key = %d, ", a[i*2]);
    printf("\n");
  }

  return 0;
}

