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

#define MIN -2000000001

typedef struct {
  int key;
  int p, r, l;
}TREE;

int main(){
  TREE *tree;
  int i, j, n;

  scanf("%d", &n);
  tree = (TREE *)malloc(sizeof(TREE)*n+1);
  
  for(i = 1; i <= n; i++){
    tree[i].p = tree[i].r = tree[i].l = MIN;
    scanf("%d", &tree[i].key);
    if(i != 1) {
      tree[i].p = tree[i/2].key;
      if(i % 2 == 0){
	tree[i/2].l = tree[i].key;
      }else{
	tree[i/2].r = tree[i].key;
      }
    }
  }
  for(i = 1; i <= n; i++){
    printf("node %d: key = %d, ", i, tree[i].key);
    if(tree[i].p != MIN) printf("parent key = %d, ", tree[i].p);
    if(tree[i].l != MIN) printf("left key = %d, ", tree[i].l);
    if(tree[i].r != MIN) printf("right key = %d, ", tree[i].r);
    printf("\n");
  }

  return 0;
}
