#include <stdio.h>

struct node{
	int key;
	int parent;
	int right;
	int left;
};

struct node tree[300];

int main(){
	int H;
	int i;
	scanf("%d",&H);
	int temp;

	for(i=0;i<H+1;i++){
		tree[i].key = -1;
		tree[i].parent = -1;
		tree[i].right = -1;
		tree[i].left = -1;
	}

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

	for(i=1;i<H+1;i++){
		tree[i].parent = i / 2;
		if(2*i<=H){
			tree[i].left = 2 * i;
		}
		if(2*i+1<=H){
			tree[i].right = 2 * i + 1;
		}
	}

	for(i=1;i<H+1;i++){
		printf("node %d: key = %d, ",i,tree[i].key);
		if(tree[i].parent!=0){
			printf("parent key = %d, ",tree[tree[i].parent].key);
		}
		if(tree[i].left!=-1){
			printf("left key = %d, ",tree[tree[i].left].key);
		}
		if(tree[i].right!=-1){
			printf("right key = %d, ",tree[tree[i].right].key);
		}
		printf("\n");
	}
	return 0;
}