#include<stdio.h>
#define NIL -1

typedef struct node{
  int parent; /*?????????????????????????????????????????????????????\???????????¨?????????*/
  int left;
  int right;
  int key;
}Node;

int parent(int );
int left(int );
int right(int );
Node A[251];

main()/*???????????\??????????????????????????????????????????*/
{
  int i,num;
  scanf("%d",&num);

  for(i=1;i<251;i++)
    {
      A[i].key = NIL;
    }


  for(i=1;i<num+1;i++) /*?????????1????????????*/
    {
      scanf("%d",&A[i].key);
      A[i].parent = parent(i);
      A[i].left = left(i);
      A[i].right = right(i);
    }

  for(i=1;i<num+1;i++)
    {
      printf("node %d: key = %d, ",i,A[i].key);
      if(A[A[i].parent].key!=NIL && i!=1)printf("parent key = %d, ",A[A[i].parent].key);
      if(A[A[i].left].key!=NIL)printf("left key = %d, ",A[A[i].left].key);
      if(A[A[i].right].key!=NIL)printf("right key = %d, ",A[A[i].right].key);
      printf("\n");
    }
  return 0;

}

int parent(int i)
{
  return i/2;
}

int left(int i)
{
  return 2*i;
}

int right(int i)
{
  return (2*i+1);
}