#include<stdio.h>
#define HS 251

int main(void){
  int hs,i;
  int a[HS];

  scanf("%d",&hs);
  for(i=1; i<=hs; i++){
    scanf("%d",&a[i]);
  }
  
  for(i=1; i<=hs; i++){
    printf("node %d: key = %d,",i,a[i]);
    if(i!=1){
      printf("parent key = %d,",a[i/2]);
    }
    if(i*2<=hs){
      printf("left key = %d,",a[i*2]);
    }
    if(i*2+1<=hs){
      printf("right key = %d,",a[i*2+1]);
    }
    printf("\n");
  } 

  return 0;
}