#include <stdio.h>
#define N 250
typedef struct node
{
  int key,left,right,parent;
  int flagl,flagr;
}T;
int main()
{
  int n,i,j;
  T tree[N];
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d",&tree[i].key);
      tree[i].flagl=0;
      tree[i].flagr=0;
      if(i!=1)
	{
	  tree[i].parent=tree[i/2].key;
	  if(i%2==0)
	    {
	      tree[i/2].left=tree[i].key;
	      tree[i/2].flagl=1;
	    }
	  else
	    {
	      tree[i/2].right=tree[i].key;
	      tree[i/2].flagr=1;
	    }
	}
    }
  for(i=1;i<=n;i++)
    {
      printf("node %d: key = %d, ",i,tree[i].key);
      if(i!=1)
	printf("parent key = %d, ",tree[i].parent);
      if(tree[i].flagl==1)
	printf("left key = %d, ",tree[i].left);
      if(tree[i].flagr==1)
	printf("right key = %d, ",tree[i].right);
      printf("\n");
    }
  return 0;
}

