#include<stdio.h>
#include<stdlib.h>
#define N 250

int parent(int);
int left(int);
int right(int);

int main(){

  int i,id[N],k[N],pk[N],lk[N],rk[N],H;


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

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

  return 0;
}

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

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

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