#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
	int length = 0;
	int *note;
	int r = 0;
	int l = 0;
	int level = 0;
	int lastR = 1;
	int ans = 0;
	printf("your note number");
	cin >>length;
	ans = length;
	while(ans != 0){
		ans = ans/2;
		level++;
	}
	for(int i =1;i<level;i++){
		lastR = lastR*2;
	}
	//printf("level = %d lastR = %d\n",level,lastR);
		
	note = new int[length] ;
	//輸入the note 
	for(int i=1;i<=length;i++){
		cin >>  note[i] ; 
	}
			
			for(int i=1;i<=length;i++){
				r = (i*2)+1;
				l = (i*2);
				//printf("r=%d,l=%d  ",r,l);
				//printf("r = %d l = %d\n",r,l);
				if(i == 1){
					printf("key = %d, ",note[i]);
					printf("left key = %d, ",note[l]);
					printf("right key = %d,",note[r]);
				
				}
				else if(i < lastR){
					printf("key = %d, ",note[i]);
					printf("parent key = %d, ",note[i/2]);
					if(l <= length)	printf("left key = %d, ",note[l]);
					if(r <= length)  printf("right key = %d,",note[r]);
				}
				else {
					printf("key = %d, ",note[i]);
					printf("parent key = %d, ",note[i/2]);
				}
				printf("\n");
			}
		
		

	
	return 0;
}
