#include <stdio.h>
#define N 251

struct node{
  int key;
  int parent;
  int left;
  int right;
} typedef Node;

int main(){
  Node heap[N];
  int h, i, j;

  scanf("%d", &h);
  for(i = 1; i < h + 1; i++){
    scanf("%d", &heap[i].key);
    heap[i].parent = 0;
    heap[i].left = 0;
    heap[i].right = 0;
  }

  for(i = 1; i < h + 1; i++){
    heap[i].left = heap[i * 2].key;
    heap[i].right = heap[i * 2 + 1].key;
    if(i != 1) heap[i].parent = heap[i / 2].key;
  }

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

    return 0;
}