//Completed Binary Tree
#include<stdio.h>
#include<limits.h>

#define MAX 251

int main(){
	int i,h;
	int H[MAX];


	//input
	scanf("%d",&h);

	//init
	for(i=0;i<=MAX;i++){
		H[i]=INT_MAX;
	}

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


	//output
	for(i=1;i<=h;i++){
		printf("node %d: key = %d, ",i,H[i]);
		if(i==1){
			printf("left key = %d, right key = %d, \n",H[2*i],H[2*i+1]);
			continue;
		}
		if(i>=125){
			printf("parent key = %d, \n",H[i/2]);
			continue;
		}
		//Left child
		if(H[2*i]!=INT_MAX){

			//Rigth child
			if(H[2*i+1]!=INT_MAX){
				printf("parent key = %d, left key = %d, right key = %d, \n",H[i/2],H[2*i],H[2*i+1]);
			}
			else{
				printf("parent key = %d, left key = %d, \n",H[i/2],H[2*i]);
			}
		}
		else{
			printf("parent key = %d, \n",H[i/2]);
		}
	}
	return 0;
}

