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

#define NIL -1

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

int n;
Node *tree;

Node* initNodeWith(int key) {
    Node *node = (Node *)malloc(sizeof(Node));
    node->key = key;
    node->parent = NIL;
    node->left = NIL;
    node->right = NIL;

    return node;
}

void printTree(int ns) {
    for (int i = 0; i < ns; i++) {
        printf("node %d: key = %d, ", i, tree[i].key);

        /// Print Keys
        if (tree[i].parent != NIL)  printf("parent key = %d, ", tree[tree[i].parent].key);
        if (tree[i].left != NIL)    printf("left key = %d, ", tree[tree[i].left].key);
        if (tree[i].right != NIL)   printf("right key = %d, ", tree[tree[i].right].key);

        printf("\n");
    }
}

int main() {
    n = 0;
    scanf("%d", &n);

    int key;
    tree = (Node *)malloc(sizeof(Node) * n);

    /// Append Nodes
    for (int i = 0; i < n; i++) {
        scanf("%d", &key);
        Node *node = initNodeWith(key);
        tree[i] = *node;
    }

    /// Refer
    for (int i = 0; i < n; i++) {
        int index = i + 1;
        if (i) tree[i].parent = index / 2 - 1;
        if (index * 2 <= n) tree[i].left = index * 2 - 1;
        if (index * 2 + 1 <= n) tree[i].right = index * 2;
    }

    printTree(n);

    free(tree);

    return 0;
}

