/*Complete Binary Tree*/
#include <stdio.h>
#include <stdlib.h>

#define N 250

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

Node a[N];

void insert(int, int);

int main(){
  int i, n, k;
  
  scanf("%d", &n);
  for (i=1; i<=n; i++){
    a[i].parent = NULL;
    a[i].left = NULL;
    a[i].right = NULL;
    scanf("%d", &k);
    insert(k, i);
  }
  
  for (i=1; i<=n; i++){
    printf("node %d: key = %d, ", i+1, a[i].key);
    if (a[i].parent != NULL)
      printf("parent key = %d, ", a[i].parent->key);
    if (a[i].left != NULL)
      printf("left key = %d, ", a[i].left->key);
    if (a[i].right != NULL)
      printf("right key = %d, ", a[i].right->key);

    printf("\n");
  }
  
  return 0;
}


void insert(int k, int j){
  
  a[j].key = k;

  if(j!=1){
    if (j%2 == 0){
      a[j/2].left = &a[j];
      a[j].parent = &a[j/2];
    }
    else{
      a[j/2].right = &a[j];
      a[j].parent = &a[j/2];
    }
  }
  
}

