#include <stdio.h>
#define MAX 251

struct heap{
  int key;
  int parent;
  int left;
  int right;
};

struct heap array[MAX];

int main(){
  int n, i;

  scanf("%d", &n);

  array[0].key = 0;

  for( i=1; i<=n; i++){
    scanf("%d", &array[i].key);
  }

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

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