#include <stdio.h>

struct heap{
  int id, k, pk, lk, rk;
};

struct heap A[250];

void print(int size){
  int i;

  for(i=1; i<=size; i++){
    printf("node %d: key = %d,", A[i].id, A[i].k);

    if( i/2 > 0 ){
      printf(" parent key = %d,", A[i].pk);
    }
    if( 2*i > 0 && 2*i <= size){
      printf(" left key = %d," , A[i].lk);
    }
    if( 2*i+1 > 0 && 2*i +1 <= size){
      printf(" right key = %d,", A[i].rk);
    }
    printf(" \n");
  }
}


main(){
  int i, size;

  scanf("%d", &size);

  for(i=1; i<=size; i++){
    scanf("%d", &A[i].k);
    A[i].id = i;
  }

  for(i=1; i<=size; i++){

    if( i/2 > 0){
      A[i].pk = A[i/2].k;
    }

    if( 2*i > 0 && 2*i <= size){
      A[i].lk = A[2*i].k;
    }

    if( 2*i +1 <= size){
      A[i].rk = A[2*i + 1].k;
    }

  }

  print(size);

  return 0;

}