#include<stdio.h>

typedef struct{
  int num;
  int p_key;
  int r_key;
  int l_key;
} Tree;

Tree data[251];

void shokika(int);

int main(){
  
  int n, i;

  scanf("%d",&n);

  for(i = 1; i <= n; i++)
    {
      shokika(i);
      
      scanf("%d",&data[i].num);

      if(i == 0)continue;

      data[i].p_key = data[i/2].num;
      if(i % 2 == 0)data[i/2].l_key = data[i].num;
      else data[i/2].r_key = data[i].num;
    }

  for(i = 1; i <= n; i++)
    {
      printf("node %d: key = %d, ", i, data[i].num);
      if(i != 1)printf("parent key = %d, ",data[i].p_key);
      if(data[i].l_key != 2000000001)printf("left key = %d, ", data[i].l_key);
      if(data[i].r_key != 2000000001)printf("right key = %d, ", data[i].r_key);
      printf("\n");
    }
   
    return 0;   
}

void shokika(int i)
{
  data[i].l_key = 2000000001;
  data[i].r_key = 2000000001;
}

