#include <stdio.h>

int heaps[255];
int h;

void parent_key(int i) {
  if ((i = i / 2) > 0)
    printf("parent key = %d, ", heaps[i]);
}

int left_key(int i) {
  if ((i = i * 2) <= h)
    printf("left key = %d, ", heaps[i]);
}

int right_key(int i) {
  if ((i = 2 * i + 1) <= h)
    printf("right key = %d, ", heaps[i]);
}

void output(int h) {
  for (int i = 1; i <= h; i++) {
    printf("node %d: key = %d, ", i, heaps[i]);
    parent_key(i);
    left_key(i);
    right_key(i);
    printf("\n");
  }
}

int main(void) {
 
  scanf("%d", &h);
  for (int i = 1; i <= h; i++)
    scanf("%d", &heaps[i]);

  output(h);
  
  return 0;
}

