#include<stdio.h>
#include<stdlib.h>
/*
int main()
{
  int *A;
  int i,n,key;

  scanf("%d",&n);
  A = malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  printf("node 1: key = %d, left key = %d, right key = %d, \n",A[0],A[1],A[2]);
  for(i=1;i<n;i++)
    {
      printf("node %d: key = %d, parent key = %d,",i+1,A[i],A[(i-1)/2]);
      if(i*2+1<n)
	{
	  printf(" left key = %d,",A[i*2+1]);
	}
      if((i+1)*2<n)
	{
	  printf(" right key = %d,",A[(i+1)*2]);
	}
      printf(" \n");
    }
  free(A);
  return 0;
}
*/

#define H 250
int main()
{
  int youso,i,haire[H];
  scanf("%d",&youso);
  for(i=1;i<=youso;i++)
    {
      scanf("%d",&haire[i]);
    }
  printf("node 1: key = %d, left key = %d, right key = %d, \n",haire[1],haire[2],haire[3]);
  for(i=2;i<=youso;i++)
    {
      printf("node %d: key = %d, parent key = %d,",i,haire[i],haire[i/2]);
      if((i*2)<=youso)
	{
	  printf(" left key = %d,",haire[i*2]);
	}
      if((i*2+1)<=youso)
	{
	  printf(" right key = %d,",haire[i*2+1]);
	}
      printf(" \n");
    }
  return 0;
}


