#include<stdio.h>

#define NIL NULL

typedef struct heap{
  int k;
  int pk;
  int lk;
  int rk;
}Heap;

int main(){
  Heap A[250];
  int i,H,p,r,l;
  
  scanf("%d",&H);

  for(i=1;i<=H;i++){
    scanf("%d",&A[i].k);
  }

  for(i=1;i<=H;i++){
    p=i/2;
    l=2*i;
    r=2*i+1;
    
    if(p!=0)
      A[i].pk=A[p].k;
    else
      A[i].pk=NIL;
    

    if(r<=H)
      A[i].rk=A[r].k;
    else
      A[i].rk=NIL;

    
    if(l<=H)
      A[i].lk=A[l].k;
    else
      A[i].lk=NIL;
  }

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

  return 0;
}

