#include <stdio.h>

#define H 10000
#define NIL -1

typedef struct{
  int k;
  int pk;
  int lk;
  int rk;
}id;

int main()
{
  int n,i;
  id A[H];

  scanf("%d",&n);

  for(i = 1;i <= n;i++)
    {
      A[i].k = NIL;
      A[i].pk = NIL;
      A[i].lk = NIL;
      A[i].rk = NIL;
    }

  for(i = 1;i <= n;i++)
    {
      scanf("%d",&A[i].k);
    }

  for(i = 1;i <= n;i++)
    {
      A[i].pk = A[i/2].k;
      A[i].lk = A[2*i].k;
      A[i].rk = A[2*i +1].k;
    }

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

