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

int Parent(int re){
  return re/2;
}

int Left(int re){
  return 2*re;
}

int Right(int re){
  return 2*re+1;
}

int check(int n,int i){
  if(n >= Right(i)) return 1;
  else if(n >= Left(i) && n < Right(i)) return 2;
  else if(n < Left(i)) return 3;
}

void Print(int *b, int num){

  int i;
  
  for(i=1;i<=num;i++){
    if(Parent(i) == 0){

      if(check(num,i) == 1) printf("node %d: key = %d, left key = %d, right key = %d, \n",i,b[i],b[Left(i)],b[Right(i)]);
      
      else if(check(num,i) == 2) printf("node %d: key = %d, left key = %d, \n",i,b[i],b[Left(i)]);
      
      else if(check(num,i) == 3) printf("node %d: key = %d, \n",i,b[i]);
    }
    
    else{
      if(check(num,i) == 1) printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,b[i],b[Parent(i)],b[Left(i)],b[Right(i)]);
      else if(check(num,i) == 2) printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,b[i],b[Parent(i)],b[Left(i)]);
      else if(check(num,i) == 3)printf("node %d: key = %d, parent key = %d, \n",i,b[i],b[Parent(i)]);
    }
    
  }
  
}

int main(){
  int num,i;
  int *BOX;

  scanf("%d",&num);

  BOX=(int *)malloc((num+1)*sizeof(int));

  for(i=1;i<=num;i++){
    scanf("%d",&BOX[i]);
  }
  
  Print(BOX,num);

  return 0;
}

