#include<stdio.h>

void print(int* t,int i,int n){
    printf("node %d: key = %d,",i,t[i]);
    if(i!=1){
        printf(" parent key = %d,",t[i/2]);
    }
    if(i*2<=n){
        printf(" left key = %d,",t[i*2]);
    }
    if(i*2+1<=n){
        printf(" right key = %d,",t[i*2+1]);
    }
    printf(" \n");
}

int main(){
    int i,H;
    scanf("%d",&H);
    int tree[H+1];
    for(i = 1 ; i <= H ; i++){
        scanf("%d",&tree[i]);
    }
    for(i = 1 ; i <= H ; i++){
        print(tree,i,H);
    }
    return 0;
}

