#include<stdio.h>
#define N 250

typedef struct{
  int key;
  int parent;
  int left;
  int right;
}node;



node Tree[N];
int main(){
  int i,n=0;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)Tree[i].parent=-1;
  
  for(i=0;i<n;i++){
    scanf("%d",&Tree[i].key);
  }

  for(i=0;i<n;i++){
    
    if(i!=0)Tree[i].parent=(i+1)/2-1;
    
    if(2*(i+1)-1<n)Tree[i].left=2*(i+1)-1;
    else Tree[i].left=-1;
    
    
    if(2*(i+1)<n)Tree[i].right=2*(i+1);
    else Tree[i].right=-1;
  }
  
  for(i=0;i<n;i++){

    printf("node %d: key = %d, ", i+1, Tree[i].key);
    
    if(Tree[i].parent!=-1) printf("parent key = %d, ",Tree[Tree[i].parent].key);
    
    if(Tree[i].left!=-1) printf("left key = %d, ",Tree[Tree[i].left].key);
    
    if(Tree[i].right!=-1) printf("right key = %d, ",Tree[Tree[i].right].key);
    
    printf("\n");
  }
  
  return 0;
}