#include<stdio.h>
#include<stdlib.h>
typedef struct Node Node;
struct Node{
    int id;
    int key;
    Node* parent;
    Node* right;
    Node* left;
};
void initialize(Node* n);
int main()
{
    int size;
    scanf("%d",&size);
    int array[size];

    for(int i = 0; i<size;i++)
    {
        scanf("%d", &array[i]);
    }
    Node a[size];
    for(int i= 0;i<size;i++)
    {
        initialize(&a[i]);
    }
    for(int i=0;i<size;i++)
    {
        a[i].id=i;
        a[i].key = array[i];
        if(2*i<size)
           a[i].left = a + (2*i);
        else 
            a[i].left = NULL;
        
        if(2*i+1<size)
            a[i].right = a + (2*i+1);
        else
            a[i].right= NULL;
        
        if(i!=0)
            a[i].parent = a + (i/2);
        else
            a[i].parent= NULL;
    }
    
    for(int i=0;i<size;i++)
    {
        printf("node %d: ",a[i].id);
        printf("key = %d. ",a[i].key);
        if(a[i].parent!=NULL)
            printf("parent key = %d, ", a[i].parent->key);
        if(a[i].left!= NULL)
            printf("left key = %d, ",a[i].left->key);
        if(a[i].right!= NULL)
            printf("right key = %d, ",a[i].right->key);
        printf("\n");
    }
    
    return 0;
}

void initialize(Node* n)
{
    n->id = -1;
    n->key = 0; 
    n->right = NULL;
    n->left = NULL;
    n->parent = NULL;
}
