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

int main(){
	int H, *A, i;

	scanf("%d", &H);
	A = (int *)malloc(sizeof(int) * (H+1));
	for(i = 1; i <= H; i++)
		scanf("%d", &A[i]);

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