#include<stdio.h>

#define N 250

void insert(int);
void Hprint(int);

int H[N];
int heapSize;

int main()
{
  int n, i, key;
  heapSize=0;
  scanf("%d", &n);
  for(i=0; i<n; i++)
    {
      scanf("%d", &key);
      insert(key);
    }
  Hprint(n);
  return 0;
}
void insert(int key)
{
  H[heapSize] = key;
  heapSize++;
}
void Hprint(int n)
{
  int i;
  for(i=0; i<n; i++)
    {
      printf("node %d: key = %d, ", i+1, H[i]);
      if((i+1)/2 >= 1)
	printf("parent key = %d, ", H[(i+1)/2 -1]);
      if((i+1)*2 <= heapSize)
	printf("left key = %d, ", H[(i+1)*2 -1]);
      if((i+1)*2 +1 <= heapSize)
	printf("right key = %d, ", H[(i+1)*2]);
      printf("\n");
    }
}