//
// Created by kota_ on 2020/01/06.
//

#include <stdio.h>
#include <stdlib.h>

void try_to_print(int n, int *A, int i, int index, char *prefix){
    if(1 <= index && index <= n){
        printf("%s = %d, ", prefix, A[index - 1]);
    }
}


int main(){
    int *A;
    int i, index,  H;
    scanf("%d", &H);
    A = malloc(sizeof(int) * H);
    for(i = 0; i < H; i++){
        scanf("%d", &A[i]);
    }
    for(i = 1; i <= H; i++){
        printf("node %d: key = %d, ", i, A[i - 1]);
        try_to_print(H, A, i, i / 2, "parent key");
        try_to_print(H, A, i, 2 * i, "left key");
        try_to_print(H, A, i, 2 * i + 1, "right key");
        printf("\n");
    }
    free(A);
    return 0;
}

