#include <stdio.h>

int parent(int n){
  return ((double)1/2)*n;
}

int left(int n){
  return 2*n;
}

int right(int n){
  return 2*n+1;
}

int main() {
  int heap_size,i,H[250];

  scanf ("%d",&heap_size);
  for (i=1;i<=heap_size;i++){
    scanf ("%d",&H[i]);
  }

  for (i=1;i<=heap_size;i++){
    printf ("node %d: key = %d, ",i,H[i]);
    if (parent(i)>=1){
      printf ("parent key = %d, ",H[parent(i)]);
    }
    if (left(i)<=heap_size){
      printf ("left key = %d, ",H[left(i)]);
    }
    if (right(i)<=heap_size){
      printf ("right key = %d, ",H[right(i)]);
    }
    printf("\n");
  }

  return 0;
}