#include<stdio.h>
#define N 250

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

int main(){
  int heap,h[N],i;
  scanf("%d",&heap);

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

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

int parent(int i){
  return (i/2);
}

int left(int i){
  return (i*2);
}

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