#include<stdio.h>
#define heap_max 250
	
int main(){
	int i,heap[heap_max],inHeap;
	
	scanf("%d",&inHeap);
	for(i=1;i<inHeap+1;i++) scanf("%d",&heap[i]);
	
	for(i=1;i<inHeap+1;i++){
		printf("node %d: key = %d,",i+1,heap[i]);
		if(i/2!=0) printf(" parent key = %d,",heap[i/2]);
		if(2*i<=inHeap) printf(" left key = %d,",heap[2*i]);
		if((2*i+1)<=inHeap) printf(" right key = %d,",heap[2*i+1]);
		if(i==inHeap) printf(" ");
		printf("\n");
		}
	return 0;
	}