#include <stdio.h>
#define N 250
  
int parent(int);
int left(int);
int right(int);
  
int A[N];
  
main()
{
    
    
  int n,i;
    
    
    
    
  scanf("%d",&n);
    
  for(i = 1; i <= n; i++){
    scanf("%d",&A[i]);
  }
    
  for(i = 1; i <= n; i++){
    if(parent(i) == 0){
      if(n >= right(i)){
    printf("node %d: key = %d, left key = %d, right key = %d, \n",i,A[i],A[left(i)],A[right(i)]);
      }
      else if(n >= left(i) && n < right(i)){
    printf("node %d: key = %d, left key = %d, \n",i,A[i],A[left(i)]);
      }
      else if(n < left(i)){
    printf("node %d: key = %d, \n",i,A[i]);
      }
    }
    else{
    if(n >= right(i)){
      printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,A[i],A[parent(i)],A[left(i)],A[right(i)]);
    }
    else if(n >= left(i) && n < right(i)){
      printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,A[i],A[parent(i)],A[left(i)]);
    }
    else if(n < left(i)){
      printf("node %d: key = %d, parent key = %d, \n",i,A[i],A[parent(i)]);
    }
    }
  }
      
  return 0;
    
}
  
int parent(int a)
{
  return a/2;
}
  
int left(int a)
{
  return 2*a;
}
  
int right(int a)
{
  return 2*a + 1;
}