#include <stdio.h>
#define N 200000
int parent(int);
int left(int);
int right(int);

int main(){
  int n,i,pk,lk,rk,k[N];


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

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

  for(i=1;i<=n;i++){
    printf("node %d: key = %d,",i,k[i]);
    pk=parent(i);
    lk=left(i);
    rk=right(i);
    if(i!=1){
      printf(" parent key = %d,",k[pk]);
    }
    if(lk<=n){
      printf(" left key = %d,",k[lk]);
    }
    if(rk<=n){
      printf(" right key = %d,",k[rk]);
    }
    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;
}