#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

int p(int i){return (i/2);}
int l(int i){return (2*i);}
int r(int i){return (2*i+1);}

main(){
	long n,i,m;
	long *A;
	scanf("%ld",&n);
	mymalloc(A,n+1);
	for(i=1;i<=n;i++){
		scanf(" %ld",&m);
		A[i]=m;
	}
	for(i=1;i<=n;i++){
		printf("node %ld: key = %ld, ",i,A[i]);
		if(i!=1){
			printf("parent key = %ld, ",A[p(i)]);
		}
		if(l(i)<=n){
			printf("left key = %ld, ",A[l(i)]);
			if(r(i)<=n){
				printf("right key = %ld, ",A[r(i)]);
			}
		}
		printf("\n");
	}
	return 0;
}