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

int parent(int i) {
	return i / 2;
}

int left(int i) {
	return 2 * i;
}

int right(int i) {
	return 2 * i + 1;
}

void print(int* node, int n) {
	int i, pk, lk, rk;

	for (i = 1; i <= n; i++) {
		printf("node %d: ", i);
		printf("key = %d, ", node[i]);
		pk = parent(i - i % 2);
		lk = left(i);
		rk = right(i);
		if (pk > 0) printf("parent key = %d, ", node[pk]);
		if (lk <= n) printf("left key = %d, ", node[lk]);
		if (rk <= n) printf("right key = %d, ", node[rk]);
		puts("");
	}
}

main() {
	int *node;
	int n, i;

	scanf("%d", &n);

	node = (int*)malloc(sizeof(int) * (n + 1));

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

	print(node, n);
	free(node);

	return 0;
}