#include<stdio.h>

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

#define MAX 251

int main(){
  Heap A[MAX];
  int i,H;

  for(i=1;i<=H;i++){
    A[i].pk=NULL;
    A[i].lk=NULL;
    A[i].rk=NULL;
  }

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

    if(i/2>=1){
      A[i].pk=A[i/2].k;
    }
    if(i%2==0){
      A[i/2].lk=A[i].k;
    }else{
      A[i/2].rk=A[i].k;
    }
  }

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

  return 0;
}