#include<stdio.h>
#include<math.h>

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

int main(){
  int T[250];
  int i,n;

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

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

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