#include <stdio.h>
#define N 250

typedef struct{
  int parent,left,right;
}node;


node H[N];

int main(){
  int i,k,s[N],n;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&s[i]);
  }

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

    if(i/2 > 0){
      H[i].parent = s[i/2];
      printf("parent key = %d, ",H[i].parent);
    }
    if(2*i <= n){
      H[i].left = s[2*i];
      printf("left key = %d, ",H[i].left);
    }
    if(2*i+1 <= n){
      H[i].right = s[2*i+1];
      printf("right key = %d, ",H[i].right); 
    }
    printf("\n");
  }
  return 0;
}