#include<stdio.h>

#define MAX 100000

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

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

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

int main(){
  int h,i,array[MAX+1];
  int a,b,c;
  
    scanf("%d",&h);
  ;
  for(i = 1;i <= h;i++){
  
    scanf("%d",&array[i]);
  }
  for(i = 1;i <= h;i++){
    printf("node %d: key = %d, ",i,array[i]);
    if(p(i) >= 1)printf(" parent key = %d,",array[a=p(i)]);
    if(l(i) <= h)printf(" left key = %d,",array[b=l(i)]);
    if(r(i) <= h)printf(" right key = %d",array[c=r(i)]);
    printf("\n");
  }
  return 0;
}

