#include<stdio.h>
#define MAX 25000
int parent(int k){return k/2;}
int lefttree(int k){return 2*k;}
int righttree(int k){return 2*k+1;}

int main()
{
  int i,size,A[MAX+1];
  
  scanf("%d",&size);
  for(i=1;i<=size;i++)scanf("%d",&A[i]);

  for(i=1;i<=size;i++)
    {
      printf("node %d: key = %d,",i,A[i]);
      if(parent(i)>=1)printf("parent key = %d,",A[parent(i)]);
      if(lefttree(i)<=size)printf("left key = %d,",A[lefttree(i)]);
      if(righttree(i)<=size)printf("right key = %d",A[righttree(i)]);
      printf("\n");
    }
  return 0;
}