#include <stdio.h>


int main(){
	
	int N;
	int i,key[1000];
	scanf("%d",&N);
	for (i = 1; i <= N; i++)	{
		scanf("%d",&key[i]);
	}

	N++;

	for(i = 1; i < N; i++){
		printf("node %d: key = %d, ",i,key[i]);
		
		if(i != 1){
			printf("parent key = %d, ",key[i/2]);
		}
		if(2*i < N){
			printf("left key = %d, ",key[2*i]);
		}
		if(2*i + 1 < N) {
			printf("right key = %d, ",key[2*i+1]);
		}
		printf("\n");
	}
	return 0;
}