#include <stdio.h>
#define N 100000

struct node{
  int id;
  int parent;
  int left;
  int right;
  int flag[3];
};

void serP(struct node *,int);

int main(){

  int h,i;
  struct node T[N];
  
  scanf("%d",&h);
  for( i = 1 ; i <= h ; i++){
    scanf("%d",&T[i].id);
  }

  serP(T,h);

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

  return 0;
}


void serP(struct node *a,int h){

  int i,parent;

  for(i = 1 ; i <= h ; i++){
    
    parent = i/2;
    if(i == 1) a[i].flag[0] = -1;
    else a[i].parent = a[parent].id;

    if(i*2 > h) a[i].flag[1] = -1;
    else a[i].left = a[i*2].id;
   

    if(i*2+1 > h) a[i].flag[2] = -1;
    else a[i].right = a[i*2+1].id;
    
  }
  
}

