#include<stdio.h>

int H;

void print(int* u, int i){
  printf("node %d: key = %d, ",i,u[i]);

  if(i/2 != 0) printf("parent key = %d, ",u[i/2]);

  if(2*i <= H) printf("left key = %d, ",u[2*i]);

  if(2*i+1 <= H) printf("right key = %d, ",u[2*i+1]);
  printf("\n");
}

int main(){
  int u[250],i;
  
  scanf("%d",&H);
  for(i=1;i<H+1;i++)  scanf("%d",&u[i]);

  for(i=1;i<H+1;i++) print(u,i);
  return 0;
}

