#include <stdio.h>

typedef struct node{
    int key;
    int parent;
    int left;
    int right;
}Tree;

int main(){
    int i,j,n;
    int data;
    int parent;
    
    scanf("%d",&n);
    Tree T[n+1];
    for(i=0;i<n+1;i++){
        T[i].key=0;
        T[i].parent=0;
        T[i].left=0;
        T[i].right=0;
    }
    
    parent=-1;
    for(i=1;i<n+1;i++){
        scanf("%d",&data);
        T[i].key=data;
        T[i].parent=T[i/2].key;
        if(T[i/2].left==-1)T[i/2].left=data;
        else T[i/2].right=data;
    }
    
    for(i=1;i<n+1;i++){
        printf("node %d: key = %d, ",i,T[i].key);
        if(T[i].parent!=0)printf("parent key = %d, ",T[i].parent);
        if(T[i].left!=0)printf("left key = %d, ",T[i].left);
        if(T[i].right!=0)printf("right key = %d, ",T[i].right);
        printf("\n");
    }
    
    return 0;
}