#include <stdio.h>
#define MAX 250

int parent(int);
int left(int);
int right(int);

int main(){
	int n,i;
	int heap[MAX];

	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&heap[i]);

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

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

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

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