#include <stdio.h>

int main(){
	int i,a;

	scanf("%d",&a);

	int A[a+1];

	for(i=1; i<a+1; i++){
		scanf("%d",&A[i]);
	}

	for(i=1; i<a+1; i++){
		printf("node %d: key = %d, ",i,A[i]);
		if(i/2 > 0)
      printf("parent key = %d, ",A[i/2]);
		if(i*2 < a+1)
      printf("left key = %d, ",A[i*2]);
		if(i*2 + 1 < a+1)
      printf("right key = %d, ",A[i*2 + 1 ]);

		printf("\n");
	}

	return 0;
}

