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

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

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

int parent(int i){ return i/2; }

int main(void){
  int i,n;
  int *Heap;


  // input and alloc
  scanf("%d",&n);
  Heap = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++) scanf("%d ",&Heap[i]);

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

  free(Heap);

  return 0;
}