#include<stdio.h>

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


int main(){
  int v, p;
  int a[512+30];
  int i;
  int r;
  scanf("%d", &v);
  i=1;
  while(i<=v){
    scanf("%d", &a[i]);
  i++;
  }
  
  

  for(i=1;i<=v;i++){
    p = i / 2;
    r = 2 * i + 1;
    printf("node %d: key = %d, ", i,a[i]); 
   
    if(i != 1) printf("parent key = %d, ", a[p]); 
    if(l(i) <= v) printf("left key = %d, ", a[l(i)]); 
    if(r <= v) printf("right key = %d, ", a[r]); 
    puts("");
  }
  
  return 0;
}
