#include <stdio.h>

#define NODE_MAX (250)

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

int
main(void)
{
        int heap_size;
        struct node key[NODE_MAX];
        int i;

        scanf("%d", &heap_size);

        for (i = 1; i <= heap_size; i++)
                scanf("%d", &key[i].key);

        for (i = 1; i <= heap_size; i++) {
                key[i].parent = i / 2;
                key[i].left = i * 2;
                key[i].right = i * 2 + 1;
        }

        for (i = 1; i <= heap_size; i++) {
                printf("node %d: key = %d, ", i, key[i].key);

                if (key[i].parent != 0)
                        printf("parent key = %d, ", key[key[i].parent].key);

                if (key[i].left <= heap_size)
                        printf("left key = %d, ", key[key[i].left].key);

                if (key[i].right <= heap_size)
                        printf("right key = %d, ", key[key[i].right].key);

                printf("\n");
        }
}

