#include <stdio.h>
#define H 250

struct a{
  int id;
  int k;
  int pk;
  int lk;
  int rk; 
};

int main()
{
  struct a node[H];
  int i, h;

  scanf("%d",&h);
  for(i=0;i<h;i++){
    scanf("%d",&node[i].k);
    node[i].id=i+1;
  }

  for(i=0;i<h;i++){
    if(i!=0){
      node[i].pk=node[node[i].id/2-1].k;
    }
    if((i+1)*2<=h){
      node[i].lk=node[2*node[i].id-1].k;
    }
    if((i+1)*2+1<=h){
      node[i].rk=node[2*node[i].id].k;
    }
  }

  for(i=0;i<h;i++){
    if(i==0) printf("node %d: key = %d, left key = %d, right key = %d, \n", i+1, node[i].k, node[i].lk, node[i].rk);

    else if((i+1)*2>h) printf("node %d: key = %d, parent key = %d, \n", i+1, node[i].k, node[i].pk);

    else if((i+1)*2+1>h) printf("node %d: key = %d, parent key = %d, left key = %d, \n", i+1, node[i].k, node[i].pk, node[i].lk);

    else printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i+1,node[i].k, node[i].pk, node[i].lk,node[i].rk);
  }
  return 0;
}
