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

#define parent(i) ((i) / 2)
#define left(i) (2 * (i))
#define right(i) (2 * (i) + 1)

int
main (void)
{
	int i, n, p;
	int *a;

	scanf("%d", &n);
	n += 1; /* 1 origin */

	a = (int *)malloc(sizeof(int) * n);
	if (a == NULL)
		return 1;

	for (i = 1; i < n; i++)
		scanf("%d", a + i);

	for (i = 1; i < n; i++) {
		printf("node %d: key = %d, ", i, a[i]);
		if (i > 1)
			printf("parent key = %d, ", a[parent(i)]);
		if (left(i) < n)
			printf("left key = %d, ", a[left(i)]);
		if (right(i) < n)
			printf("right key = %d, ", a[right(i)]);
		printf("\n");
	}

	return 0;
}

