/* ALDS1_9_A_CompleteBinaryTree */
/* 20181129 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#define H 251
#include <stdio.h>

void printHeap(int *heap, int n);

int main(void) {
	int n, i;
	int heap[H] = {0};

	scanf("%d", &n);
	for (i = 1; i <= n; i++){
		scanf("%d", heap + i);
	}

	printHeap(heap, n);

	return 0;
}

void printHeap(int *heap, int n) {
	int id, parentId, leftId, rightId;
	for (id = 1; id <= n; id++) {
		printf("node %d: key = %d, ", id, heap[id]);
		parentId = id / 2;
		leftId = 2 * id;
		rightId = leftId + 1;
		if (parentId >= 1) printf("parent key = %d, ", heap[parentId]);
		if (leftId <= n) printf("left key = %d, ", heap[leftId]);
		if(rightId <= n) printf("right key = %d, ", heap[rightId]);
		printf("\n");
	}
}
