#include<stdio.h>
#define N 250

typedef struct
{
  int key,l,r,p;
}Bin;

void cbt(Bin *,int );
void Print(Bin *,int);

int main()
{
  int i,n;
  Bin H[N];

  scanf("%d",&n);

  for(i=1;i<=n;i++)
  {
    scanf("%d",&H[i].key);
    H[i].l = H[i].r = 0;
  }

cbt(H,n);

Print(H,n);
  return 0;
}

void cbt(Bin *H,int n)
{
  int i;
  for(i=1;i<=n;i++)
  {
    if(2*i <= n)H[i].l = H[2*i].key;
    if(2*i+1 <= n)H[i].r = H[2*i+1].key;
    if(i!=0)H[i].p = H[i/2].key;
  }
}

void Print(Bin *H,int n)
{
  int i;
  for(i=1;i<=n;i++)
  {
    printf("node %d: key = %d, ",i,H[i].key);
    if(i!=1)printf("parent key = %d, ",H[i].p);
    if(H[i].l != 0 )printf("left key = %d, ",H[i].l);
    if(H[i].r != 0)printf("right key = %d, ",H[i].r);
    printf("\n");
  }
}

