#include <stdio.h>
#define INF 2000000001
int heap[250];
int size;

void maxHeapInsert(int);
void heapIncreaseKey(int);
int main (){
    int n,i,tmp;
    scanf("%d",&n);
    size=0;
    for(i=0;i<n;i++){
        scanf("%d",&tmp);
        maxHeapInsert(tmp);
    }
    for(i=1;i<=n;i++){
        printf("node %d: key = %d, ",i,heap[i]);
        if(i/2>0){
            printf("parent key = %d, ",heap[i/2]);
        }
        if(i*2<=n){
            printf("left key = %d, ",heap[i*2]);
        }
        if(i*2+1<=n){
            printf("right key = %d, ",heap[i*2+1]);
        }
        printf("\n");
    }
    return 0;
}
void maxHeapInsert(int key){
    size++;
    heap[size]=key;
    /*
    heap[size]=-INF;
    heapIncreaseKey(key);
    */
}
void heapIncreaseKey(int key){
    int i,tmp;
    i=size;
    heap[i]=key;
    while(i>1 && heap[i/2]<heap[i]){
        tmp=heap[i];
        heap[i]=heap[i/2];
        heap[i/2]=tmp;
        i=i/2;
    }
}
