#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(){
    int H, i, *array;
    
    scanf("%d", &H);
    array = (int*)malloc(sizeof(array));
    
    for(i=0; i < H; i++){
        scanf("%d", &array[i]);
    }
    
    for(i = 0; i < H; i++){
        printf("node %d:", i+1);
        printf(" key = %d,", array[i]);
        if((i-1) >= 0) printf(" parent key = %d,", array[(i-1)/2]);
        if(2*i + 1 < H) printf(" left key = %d,", array[2*i + 1]);
        if(2*i + 2 < H) printf(" right key = %d,", array[2*i + 2]);
        printf("\n");
    }
    return 0;
}