#include<stdio.h>

#define H 250
#define NIL -200000
 
int main(){

  
   int A[H], i, n;

   for(i = 0 ; i < H ; i++)
     A[i] = NIL;

   scanf("%d",&n);
 
   for(i = 0 ; i < n ; i++)
      scanf("%d",&A[i]);
    
 
    for(i = 0 ; i < n ; i++){
     printf("node %d: ",i+1);
     if(i ==0 )    
       printf("key = %d, left key = %d, right key = %d, \n",A[i],A[i + 1],A[i +2]);
     else if(A[2*(i+1)] != NIL  &&  A[2*i+1] != NIL) 
        printf("key = %d, parent key = %d, left key = %d, right key = %d, \n",A[i],A[(i-1)/2],A[2*i+1],A[2*(i+1)]);
     else if(A[2*(i+1)] == NIL  &&  A[2*i+1] != NIL)
       printf("key = %d, parent key = %d, left key = %d, \n",A[i],A[(i-1)/2],A[2*i+1]);
     else 
       printf("key = %d, parent key = %d, \n",A[i],A[(i-1)/2]);
   } 
 return 0;
}