#include<stdio.h>
#include<stdlib.h>

int parent(int);
int left(int);
int right(int);

int main()
{
  int n,i;
  int heap[251];

  heap[0] = 0;

  scanf("%d",&n);

  for(i = 1; i <= n; i++){
    scanf("%d",&heap[i]);
  }

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

  return 0;
}

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

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

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

