//完全二分木
//2019-01-15
//Ebitani Akira

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

#define N 250

int Right(int);
int Left(int);

int array[N];
int n;

int main(){
  int i;

  scanf("%d", &n);
  if(n < 1 || n > 250){
    printf("サイズが適当ではありません。\n");
    exit(1);
  }

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

    if(i > 1){
      printf(" parent key = %d,", array[i/2]);
    }

    if(Left(i) <= n){
      printf(" left key = %d,", array[Left(i)]);
    }
    if(Right(i) <= n){
      printf(" right key = %d,", array[Right(i)]);
    }
    
    printf(" \n");
  }

  return 0;
}

int Right(int x){
  int re;
  re = 2 * x + 1;
  return re;
}
int Left(int x){
  int re;
  re = 2 * x;
  return re;
}

