#include <stdio.h>
int main() {
	int h,i,key[250];
	
	scanf("%d",&h);
	
	for(i=1;i<=h;i++) scanf("%d",&key[i]);
	
	for(i=1;i<=h;i++){
		if(i==1) printf("node 1: key = %d, left key = %d, right key = %d, ",key[i],key[i*2],key[i*2+1]);
		else if((i*2+1)<=h) printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, ",i,key[i],key[i/2],key[i*2],key[i*2+1]);
		else if(i*2==h) printf("node %d: key = %d, parent key = %d, left key = %d, ",i,key[i],key[i/2],key[i*2]);
		else printf("node %d: key = %d, parent key = %d, ",i,key[i],key[i/2]);
		printf("\n");
	}
	
	return 0;
}

