#include <stdio.h>
#define NIL -2000000001

int main(void){
  int i,H;

  scanf("%d", &H);

  //1 origin
  int heap[H+1];
  for(i = 0; i <= H; i++)
    heap[i] = NIL;

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

  for(i = 1; i <= H; i++){
    printf("node %d: ", i);
    printf("key = %d, ", heap[i]);
    if(heap[i/2] != NIL && i/2 <= H && i/2 >= 0)
      printf("parent key = %d, ", heap[i/2]);
    if(heap[2*i] != NIL && 2*i <= H && 2*i >= 0)
      printf("left key = %d, ", heap[2*i]);
    if(heap[2*i+1] != NIL && 2*i+1 <= H && 2*i+1 >= 0)
      printf("right key = %d, ", heap[2*i+1]);
    printf("\n");
  }
  return 0;
}