#include <stdio.h>

#define MAX 2000000001

typedef struct{
  int key;
  int p;
  int l;
  int r;
}Heap;

int main(){
  int i,h;
  Heap heap[251];
  
  scanf("%d",&h);

  for(i = 1;i <= h; i++){
    scanf("%d",&heap[i].key);
  }
  
  for(i = 1;i <= h; i++){
   if(i == 1){
      heap[i].p = MAX;
    }
    else heap[i].p = heap[i/2].key;
    if(2*i > h)heap[i].l = MAX;
    else  heap[i].l = heap[2*i].key;

    if(2*i+1 > h)heap[i].r = MAX;
    else  heap[i].r = heap[2*i+1].key;
  }
  for(i = 1;i <= h; i++){
   
   printf("node %d: key = %d, ",i,heap[i].key);
   if(heap[i].p != MAX)printf("parent key = %d, ",heap[i].p);
   if(heap[i].l != MAX)printf("left key = %d, ",heap[i].l);
   if(heap[i].r != MAX)printf("right key = %d, ",heap[i].r);
   printf("\n");
  }
  return 0;
}

