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


/*typedef struct{
  int id;
  int parentkey;
  int leftkey;
  int rightkey;
  int key;
  } Node;*/

int main(){
  int H,i,n;
  int *key;
  // Node *node;

  scanf("%d",&H);
  //  node=malloc(sizeof(node));
  key=(int *)malloc(sizeof(int)*H);

  for(i=0;i<H;i++){
    //  scanf("%d",&node[i]->key);
    //node[i]->id=i+1;
    scanf("%d",&key[i]);

  }

  for(i=0;i<H;i++){
    printf("node %d: ",i+1);
    printf("key = %d, ",key[i]);
    
    if(i!=0){
      printf("parent key = %d, ",key[(i+1)/2-1]);
    }
    if((i+1)*2 <= H){
      printf("left key = %d, ",key[(i+1)*2-1]);
    }
    if((i+1)*2 + 1 <= H){
      printf("right key = %d, ",key[(i+1)*2]);
    }
    printf("\n");
  }

  free(key);
			       

  return 0;
}