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

#define MAX 250
#define NIL -1

struct Node{
    int key;
    int right;
    int left;
    int parent;
};

int main(){
    int n;
    int key[MAX];
    struct Node node[MAX];

    scanf("%d",&n);

    for(int i = 1;i <= n;i++){
        scanf("%d",&key[i]);
        node[i].right = node[i].left = node[i].parent = NIL;
    }

    for(int i = 1;i <= n;i++){
        node[i].key = key[i];
        if((i * 2 + 1) <= n){
            node[i].right = key[i * 2 + 1];
        }
        if((i * 2) <= n){
            node[i].left = key[i * 2];
        }
        if(i >= 2){
            node[i].parent = key[i / 2];
        }
    }

    for(int i = 1;i <= n;i++){
        printf("node %d: key = %d, ",i,node[i].key);
        if(node[i].parent != NIL){
            printf("parent key = %d, ",node[i].parent);
        }
        if(node[i].left != NIL){
            printf("left key = %d, ",node[i].left);
        }
        if(node[i].right != NIL){
            printf("right key = %d, ",node[i].right);
        }
        printf("\n");
    }

    return 0;
}
