#include <stdio.h>
#include <math.h>
#include <string.h>
#define MAX 255
#define NIL -1

typedef struct{ 
	int pk, lk, rk, key;
}node;

node T[MAX];
int i, h, id;

int parent(int x){
	return floor(x/2);
}
	
int left(int x){
	return 2*x;
}

int right(int x){
	return 2*x + 1;
}


int main(void) {
	scanf("%d", &h);
	
	//initialize
	for (i=1; i<=h; i++){
		T[i].pk = T[i].lk = T[i].rk = T[i].key = NIL;
	}
	
	for(i=1; i<=h; i++){
		scanf("%d", &id);
		T[i].key = id;
		T[i].pk = T[parent(i)].key;
	}

	
	for(i=1; i<=h; i++){
		T[i].lk = T[left(i)].key;
		T[i].rk = T[right(i)].key;
		printf("node %d: key = %d, ", i, T[i].key);
		if (i/2 > 0)
			printf("parent key = %d, ", T[i].pk);
		if (i*2 <= h)
			printf("left key = %d, ", T[i].lk);
		if ((i*2 + 1) <= h)
			printf("right key = %d, ", T[i].rk);
		printf("\n");
	}
	
	return 0;
}




