#include <stdio.h>

int main()
{
  int key[10000];
  int h=0,i=0,k=0;

  //入力
  scanf("%d",&h);

  for(i=1;i<=h;i++)
    {
      scanf("%d",&key[i]);
    }

  //計算出力

  for(i=1;i<=h;i++)
    {
      printf("node %d: ",i);
      printf("key = %d, ",key[i]);

      //parent の判定
       if(i!=1)
	{
	  if(i%2==0)
	    {
	      printf("parent key = %d, ",key[i/2]);
	    }
	  else
	    {
	      k=i-1;
	      printf("parent key = %d, ",key[k/2]);
	    }
	}
       //right left key　の判定
       if((i*2)+1 <= h)
	 {
	   printf("left key = %d, ",key[2*i]);
	   printf("right key = %d, ",key[(2*i)+1]);
	 }
       //right keyがない場合
       else if(i*2 == h)
	 {
	   printf("left key = %d, ",key[2*i]);
	 }
       printf("\n");
    }
  return 0;
}

