#include <stdio.h>
#define NIL -2000000001
 
int main(void){
  int i,h;

  scanf("%d",&h);

  int heap[h+1];
  for(i=0; i<=h; i++)
    heap[i] = NIL;
 
  for(i=1; i<=h; i++)
    scanf("%d",&heap[i]);
 
  for(i=1; i<=h; i++){
    printf("node %d: ",i);
    printf("key = %d, ",heap[i]);
    if(heap[i/2]!=NIL && i/2<=h && i/2>=0)
      printf("parent key = %d, ",heap[i/2]);
    if(heap[2*i]!=NIL && 2*i<=h && 2*i>=0)
      printf("left key = %d, ",heap[2*i]);
    if(heap[2*i+1]!=NIL && 2*i+1<=h && 2*i+1>=0)
      printf("right key = %d, ",heap[2*i+1]);
    printf("\n");
  }
  return 0;
}