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

typedef struct{

  int k;
  int pk;
  int lk;
  int rk;
  int h;

}Node;
  
int main(){
  int h,i,s;

  Node *node;
  
  scanf("%d",&h);

  node = (Node *)malloc(sizeof(Node) * h);
  
  for(i = 0 ; i < h ; i++) scanf("%d",&node[i].k);
  
  for(i = 0 ; i < h ; i++){
    node[i].h = i+1;
  }
  
  for(i = 0 ; i < h ; i++){
    if(i == 0){
      s = node[i].h;
      
      node[i].pk = 0;
      node[i].lk = node[2 * s - 1].k;
      node[i].rk = node[2 * s].k;
    }
    else if(i <= (h / 2)){
      s = node[i].h;
      
      node[i].pk = node[(s/2) - 1].k;
      node[i].lk = node[2 * s - 1].k;
      node[i].rk = node[2 * s].k;
    }

    else{
      s = node[i].h;
      
      node[i].pk = node[(s/2) -1].k;
      
    }
  }


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

  return 0;
}