#include <stdio.h>

void Heap(int, int);


int H, A[100001];
int main(){
  int i;

scanf("%d", &H);
for(i = 1; i<=H; i++){
  scanf("%d", &A[i]);
}

Heap(1, H);

return 0;
}


void Heap(int j, int M) {
  A[0] = 0;
  for(j = 1; j <= M; j++){
  printf("node %d:key = %d, ", j, A[j]);

if(j/2 >= 1) printf("parent key = %d, ", A[j/2]);
if(2 * j <= M) printf("left key = %d, ", A[j*2]);
if(2 * j +1 <= M) printf("right key = %d, ", A[j*2+1]);
printf("\n");
}
}