// Heap i
#include <stdio.h>
#include <stdlib.h>

typedef struct node {
  int key;
  struct node* parent;
  struct node* left;
  struct node* right;
} node_p;

void heapSort();

int main() {
  int i;
  int n;
  node_p *node;
  node_p *z;

  // input
  scanf("%d", &n);

  // memory allocate
  node = (node_p*)malloc((n+1) * sizeof(node_p));

  // input the key of node
  for(i = 1; i <= n; i++) {
    scanf("%d", &node[i].key);
    if(i == 1) {
      node[i].parent = NULL;
    }
    else {
      if(i % 2 == 0) node[i/2].left = &node[i];
      else node[i/2].right = &node[i];
      node[i].parent = &node[i/2];
    }
    node[i].left = NULL;
    node[i].right = NULL;
  }

  // output
  for(i = 1; i <= n; i++) {
    printf("node %d: ", i);
    printf("key = %d, ", node[i].key);
    if(node[i].parent != NULL) printf("parent key = %d, ", node[i].parent->key);
    if(node[i].left != NULL) printf("left key = %d, ", node[i].left->key);
    if(node[i].right != NULL) printf("right key = %d, ", node[i].right->key);
    printf("\n");
  }
  

  return 0;
}


