#include<stdio.h>
#define MAX 260
#define NIL -1

int Tree[MAX];

int n;

void maxHeapify(int i){
  int largest,exchange,r,l;
  l = getLeft(i);
  r = getRight(i);
  
  if(n>=l && Tree[l]>Tree[i])
    largest = r;
  if (largest != i){
    exchange =  Tree[i];
    Tree[i] = Tree[largest];
    Tree[largest] = exchange;
  }
  maxHeapify(largest);
}


int getParent(int i){
  return i/2;
}

int getLeft(int i){
  return (2*i);
}

int getRight(int i){
  return (2*i + 1);
}

main()
{
  int i;
  scanf("%d",&n);

  for(i=1; i<=n; i++){

    scanf("%d",&Tree[i]);

  }

  for(i=1; i<=n; i++){
    
    printf("node %d: key = %d, ",i,Tree[i]);
    if(getParent(i) != 0)printf("parent key = %d, ",Tree[getParent(i)]);
    if(getLeft(i) <= n) printf("left key = %d, ",Tree[getLeft(i)]);
    if(getRight(i) <= n)printf("right key = %d, ",Tree[getRight(i)]);
    printf("\n");
  }
  return 0;
}