#include <stdio.h>
#include <stdlib.h>

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

main(){
  int i,n;
  N node[252];

  scanf("%d", &n);

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

  for(i = 1;i <= n;i++){
    if(2*i <= n) node[i].right = node[2*i].key;
    if(2*i + 1 <=  n) node[i].left = node[2*i+1].key;
    if(i/2 > 0) node[i].parent = node[i/2].key;
  }

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