#include<stdio.h>

int main()
{
  int n,i;
  int k[250],pk[250],lk[250],rk[250];
  
  scanf("%d",&n);
  for(i = 1;i < n+1;i++){
    scanf("%d",&k[i]);
  }

  for(i = 1;i < n+1;i++){
    printf("node %d: key = %d, ",i,k[i]);
    if(i != 1){
      pk[i] = k[i/2];
      printf("parent key = %d, ",pk[i]);
    }
    if(i*2 < n+1){
      lk[i] = k[2*i];
      printf("left key = %d, ",lk[i]);
    }
    if(i*2+1 < n+1){
      rk[i] = k[2*i+1];
      printf("right key = %d, ",rk[i]);
    }
    printf("\n");
  }
  return 0;
}

