#include <stdio.h>
#include <stdlib.h>


int searchParent(int p) {
  if( p != 1 ) {
    return (int)p/2;
  }else {
    return -1;
  }
}


int searchLeft(int p, int n) {
  if( p*2 <= n ) {
    return p*2;
  }else {
    return -1;
  }
}


int searchRight(int p, int n) {
  if( p*2+1 <= n ) {
    return p*2+1;
  }else {
    return -1;
  }
}


void printHeap(int* h, int n) {
  int i;

  for( i=1; i<=n; i++) {
    printf("node %d: key = %d, ", i, h[i]);
    if( searchParent(i) != -1 ) {
      printf("parent key = %d, ", h[searchParent(i)]);
    }
    if( searchLeft(i, n) != -1 ) {
      printf("left key = %d, ", h[searchLeft(i, n)]);
    }
    if( searchRight(i, n) != -1 ) {
      printf("right key = %d, ", h[searchRight(i, n)]);
    }
    printf("\n");
  }
}


int main() {

  int n; //heapSize
  int* h; //heapPointer

  int i;

  scanf("%d", &n);

  h = (int*)malloc( sizeof(int) * (n + 1) );

  //Heapは1から始まる
  for( i=1; i<=n; i++) {
    scanf("%d", &h[i]);
  }

  printHeap(h, n);

  return 0;

}