#include<stdio.h>

int parent(int);
int left(int);
int right(int);



int main()
{
	int H,p,r=NULL,l=NULL,i;
	scanf("%d",&H);
	int A[H+1];
	for(i=1;i<=H;i++) scanf("%d",&A[i]);	
    
    for(i=1;i<=H;i++)
    {
    
    p=parent(i);
    l=left(i);
    r=right(i);
    
    printf("node %d: key = %d, ",i,A[i]);
    if(i>1)printf("parent key = %d, ",A[p]);
    if(l<=H)printf("left key = %d, ",A[l]);
    if(r<=H)printf("right key = %d, ",A[r]);
    
    printf("\n");
    
    }
	
	return 0;

}


int parent(int i)
{
	return i/2;
}
int left(int i)
{
	return 2*i;
}
int right(int i)
{
	return 2*i+1;
}

