#include<stdio.h>
#include<stdlib.h>
void printHeap(int*,int);
int parent(int);
int left(int);
int right(int);
int main(void)
{
  int i;//counter
  int n;//the size of binary heap
  int *arr;//heap array
  scanf("%d",&n);
  arr=(int*)malloc(sizeof(int)*(n+1));
  for(i=1;i<=n;i++) scanf("%d",&arr[i]);
  printHeap(arr,n);
  return 0;
}
void printHeap(int *arr,int n)
{
  int i;//counter
  for(i=1;i<=n;i++)
    {
      printf("node %d: ",i);
      printf("key = %d, ",arr[i]);
      if(parent(i)>=1) printf("parent key = %d, ",arr[parent(i)]);
      if(left(i)<=n) printf("left key = %d, ",arr[left(i)]);
      if(right(i)<=n) printf("right key = %d, ",arr[right(i)]);
      printf("\n");
    }
  
}
int parent(int i)
{
  return i/2;
}
int left(int i)
{
  return 2*i;
}
int right(int i)
{
  return 2*i+1;
}

