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

typedef struct {
    int key;
} Node;

typedef struct {
    Node *node;
    int size;
} Heap;

int getParent(int idx) {
    return idx / 2;
}

int getLeft(int idx) {
    return idx * 2;
}

int getRight(int idx) {
    return idx * 2 + 1;
}

bool isCorrectHeapIdx(int idx, int heapSize) {
    return 1 <= idx && idx <= heapSize;
}

bool initialize(Heap *heap, int size) {
    if((heap->node = malloc((size + 1) * sizeof(Node))) == NULL) {
        return false;
    }

    heap->size = size;
    return true;
}

void printHeap(Heap *heap) {
    for(int i = 1; i <= heap->size; i++) {
        printf("node %d: ", i);
        printf("key = %d, ", heap->node[i].key);

        int parent = getParent(i);
        int left = getLeft(i);
        int right = getRight(i);
        if(isCorrectHeapIdx(parent, heap->size)) {
            printf("parent key = %d, ", heap->node[parent].key);
        } if(isCorrectHeapIdx(left, heap->size)) {
            printf("left key = %d, ", heap->node[left].key);
        } if(isCorrectHeapIdx(right, heap->size)) {
            printf("right key = %d, ", heap->node[right].key);
        }
        puts("");
    }
}

void terminate(Heap *heap) {
    free(heap->node);
    heap->node = NULL;
    heap->size = 0;
}

int main(void) {
    int n;
    Heap heap;

    scanf("%d", &n);
    initialize(&heap, n);

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

    printHeap(&heap);

    terminate(&heap);
    return 0;
}
