#include <stdio.h>

int heap[2000001];

main() {
  int i, n;

  scanf("%d", &n);

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

  for(i = 1; i < n + 1; i++) {
    if(i == 1) {
      printf("node %d: key = %d, left key = %d, right key = %d,\n", i, heap[i], heap[2 * i], heap[2 * i + 1]);
    }

    else if(i != 1 && (2 * i + 1) > n) {
      printf("node %d: key = %d, parent key = %d,\n", i, heap[i], heap[i / 2]);
    }

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