#include<stdio.h>
#define MAX_SIZE 256
#define INF 2000000001

int FindParent(int *tree, int i){
    if(i==1) return INF;
    return tree[i/2];
}

int Left(int *tree, int i,int size){
    if(i>(size/2) || (i*2)>size) return INF;
    return tree[i*2];
}

int Right(int *tree, int i, int size){
    if(i>(size/2) || (i*2+1)>size) return INF;
    return tree[i*2+1];
}

int main(){
    int tree[MAX_SIZE];
    int num,i,parent,left,right;

    scanf("%d",&num);
    for(i=1;i<=num;i++){
        scanf("%d",&tree[i]);
    }

    for(i=1;i<=num;i++){
        printf("node %d: key = %d,",i,tree[i]);
        parent = FindParent(tree,i);
        left = Left(tree,i,num);
        right = Right(tree,i,num);
        if(parent != INF) printf(" parent key = %d,",parent);
        if(left != INF) printf(" left key = %d,",left);
        if(right != INF)printf(" right key = %d,",right);
        printf(" \n");
    }
    return 0;
}
