#include <stdio.h>
#define H 251

void swap(int a, int b){
  int temp;
  temp = a;
  a = b;
  b = temp;
}

void Max_Heapify( int *A, int i){

  int l = i*2;
  int r = i*2 + 1;
  int largest;

  if(l <= H && A[l] > A[i]){
    largest = l;
  }else{
    largest = i;
  }

  if(r <= H && A[i] > A[largest]){
    largest = r;
  }
  if(largest != i){
    swap(A[i] , A[largest]);
    Max_Heapify(A, largest);
  }
}


int main(){

  int A[H], heap, i;

  A[0] = 0;

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

  Max_Heapify( A, heap/2);


  for(i = 1; i <= heap; i++){
    printf("node %d: key = %d, ", i, A[i]);
    if(A[i/2] != NULL){
      printf("parent key = %d, ", A[i/2]);
    }
    if(A[i*2] != NULL){
      printf("left key = %d, ", A[i*2]);
    }
    if(A[i*2 + 1] != NULL){
    printf("right key = %d, ", A[i*2 + 1]);
    }
    printf("\n");
  }
  return 0;
}