#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct node{
  int key;
  int parent;
  int left;
  int right;
}node;
int main(){
  int i, n;
  node N[20];
  scanf("%d",&n);
  for(i = 1; i <= n; i++)
    scanf("%d",&N[i].key);
  for(i = 1; i <= n; i++){
    N[i].parent = N[i/2].key;
    N[i].left = N[2*i].key;
    N[i].right = N[2*i+1].key;
  }

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