#include<stdio.h>
#include<math.h>
#define MAX 250

typedef struct node{
  int l;
  int r;
  int p;
  int key;
}Node;

Node A[MAX];

int main(){
  int H;
  int i;

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

  for(i=1;i<=H;i++){
    A[i].l=2000000001;
    A[i].r=2000000001;
    A[i].p=2000000001;
  }

  for(i=1;i<=H;i++){
    if((i/2)>0 && A[i].p==2000000001)A[i].p=A[i/2].key;

    if((2*i)<=H && A[i].l==2000000001)A[i].l=A[i*2].key;

    if((2*i+1)<=H && A[i].r==2000000001)A[i].r=A[i*2+1].key;
  }


  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i].key);

    if(A[i].p!=2000000001)printf("parent key = %d, ",A[i].p);

    if(A[i].l!=2000000001)printf("left key = %d, ",A[i].l);

    if(A[i].r!=2000000001)printf("right key = %d, ",A[i].r);
    
    printf("\n");
    


  }
  return 0;
}

