#include<stdio.h>

typedef struct node_tag
{
  int key;
  int parent,left,right;
}Node;

//static Node *make_node(int value);

int main()
{
  int i;
  int H,value;
  Node node[251];

  scanf("%d",&H);

  for(i=1;i<251;i++)
  {
    node[i].key = -2000000001;
    node[i].left = -2000000001;
    node[i].right = -2000000001;
    node[i].parent = -2000000001;
  }

  //scan
  for(i=1;i<=H;i++)
  {
    scanf(" %d",&value);
    if(i==1)
    {
      node[1].key = value;
    }
    else
    {
      node[i].key = value;
      if(i%2 == 0)
      {
        node[i/2].left = node[i].key;
      }
      if(i%2 == 1)
      {
        node[i/2].right = node[i].key;
      }
      if(i != 1)
      {
        node[i].parent = node[i/2].key;
      }
    }
  }
  
  //printf("%d",node[1].left);

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

}
}
*/


/*  for(i=0;i<H;i++)
{
printf("/ %d /",&node[i].key);
}
*/


//print
   for(i=1;i<=H;i++)
     {
       printf("node %d: ",i);
       printf("key = %d, ",node[i].key);
       if(i!=1)
	 {
	   printf("parent key = %d, ",node[i].parent);
	 }
       if(node[i].left != -2000000001)
	 {
	   printf("left key = %d, ",node[i].left);
	 }
       if(node[i].right != -2000000001)
	 {
	   printf("right key = %d, ",node[i].right);
	 }
       printf("\n");
     }
return 0;
}


/*static Node *make_node(int value)
{
Node *new_node;
new_node = (Node *)malloc( sizeof(node_t) );
if( new_node == NULL)
{
return NULL;
}
new_node->key = value;
new_node->left = NULL;
new_node->right = NULL;
return new_node;
}*/

