#include<stdio.h>
#define H 250

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

int main(){
  int i,n,heaps[H+1];
  int lk,rk;

  scanf("%d",&n);

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

  for(i=1;i<=n;i++){
    printf("node %d: key = %d,",i,heaps[i]);
    if(i>1){
      printf("parent key = %d, ",heaps[parent(i)]);
    }
    rk=right(i);
    lk=left(i);
    if(lk<=n){
      printf("left key = %d, ",heaps[lk]);
    }
    if(rk<=n){
      printf("right key = %d, ",heaps[rk]);
    }
    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;
}
   