#include <stdio.h>
#define N 2000000

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

int main(){
  int i,Heap,T[N+1];

  scanf("%d",&Heap);

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

  for(i=1; i<=Heap; i++){
    printf("node %d: key = %d, ",i,T[N]);
    if(parent(i) >= 1) printf("parent key = %d, ",T[parent(i)]);
    if(left(i) <= Heap)printf("left key = %d, ",T[left(i)]);
    if(right(i) <= Heap) printf("right key = %d, ",T[right(i)]);
    printf("\n");
  }
  return 0;
}

