#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main(int argc, char *argv[])
{
  int H, i;
  int *node;
  int parent, left, right;
 
  scanf("%d", &H);
  node = (int *)malloc(sizeof(int) * (H + 1));
  for (i = 1; i <= H; i++) scanf("%d", &node[i]);
 
  for (i = 1; i <= H; i++) {
    printf("node %d: key = %d, ", i, node[i]);
    parent = (int)floor(i/2.0);
    left = 2 * i;
    right = 2 * i + 1;
    if (1 <= parent && parent <= H) printf("parent key = %d, ", node[parent]);
    if (1 <= left && left <= H) printf("left key = %d, ", node[left]);
    if (1 <= right && right <= H) printf("right key = %d, ", node[right]);
    printf("\n");
  }
 
  return 0;
}

