#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);
  for(i=0;i<n;i++) scanf("%d",&arr[i]);
  printHeap(arr,n);
  return 0;
}
void printHeap(int *arr,int n)
{
  int i;//counter
  for(i=0;i<n;i++)
    {
      printf("node %d: ",i+1);
      printf("key = %d, ",arr[i]);
      if(parent(i)>=0) 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+1)/2-1;
}
int left(int i)
{
  return 2*(i+1)-1;
}
int right(int i)
{
  return (2*(i+1)+1)-1;
}
