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

#define	NASI	2000000001

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

TREE_T *TREE;

int main()
{
	int n;
	int key;
	int i;

	scanf("%d", &n);

	TREE = (TREE_T *)malloc(sizeof(TREE_T) * (n + 1));

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

	for(i = 1; i <= n; i++)
		TREE[i].parent = TREE[i].left = TREE[i].right = NASI;

	// parent, left, right key の情報を不可する
	for(i = 1; i <= n; i++){
		// parent
		if(i / 2 > 0)
			TREE[i].parent = TREE[i / 2].key;
		// left
		if(i * 2 <= n)
			TREE[i].left = TREE[i * 2].key;
		// right
		if(i * 2 + 1 <= n)
			TREE[i].right = TREE[i * 2 + 1].key;
	}

	// 表示
	for(i = 1; i <= n; i++){
		printf("node %d: key = %d, ", i, TREE[i].key);
		if(TREE[i].parent != NASI)
			printf("parent key = %d, ", TREE[i].parent);
		if(TREE[i].left != NASI)
			printf("left key = %d, ", TREE[i].left);
		if(TREE[i].right != NASI)
			printf("right key = %d, ", TREE[i].right);
		printf("\n");
	}

	return 0;
}
