#include <stdio.h>
#include <math.h>

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