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

typedef struct {
  int k;
  int pk;
  int lk;
  int rk;
} Array;

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i + 1;
}

int main(){
  int i, H;
  Array *A;

  scanf("%d ",&H);
  A = (Array *)malloc(sizeof(Array) * (H+1));
  for(i=1; i<=H; i++){
    scanf("%d ",&A[i].k);
  }

  for(i=1; i<=H; i++){
    printf("node %d: key = %d, ",i, A[i].k);
    if(parent(i) != 0){
      A[i].pk = A[parent(i)].k;
      printf("parent key = %d, ",A[i].pk);
    }
    if(left(i) <= H){
      A[i].lk = A[left(i)].k;
      printf("left key = %d, ",A[i].lk);
    }
    if(right(i) <= H){
      A[i].rk = A[right(i)].k;
      printf("right key = %d, ",A[i].rk);
    }
    puts("");
  }



  return 0;
}

