#include <stdio.h>
#include <stdlib.h>

int main()
{
  int H,*A,i;
  
  scanf("%d",&H);

  A = (int *)malloc((H+1) * sizeof(int));

  for(i=0;i<H;i++){
    scanf("%d",&A[i+1]);
    
  }

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

  free(A);
  return 0;
}
    

