#include<stdio.h>
 
int heap[1000];
 
void output(int k, int n){
    printf("node %d: key = %d, ", k, heap[k]);
    if( k/2 > 0 ){ printf("parent key = %d, ", heap[k/2]); }
    if( k*2 <= n ){ printf("left key = %d, ", heap[k*2]); }
    if( k*2 + 1 <= n ){ printf("right key = %d, ", heap[k*2+1]); }
    printf("\n");
    return;
}
 
int main(){
    int n, i;
    scanf("%d", &n);
    for( i = 1; i <= n; i++ ){ scanf("%d", &heap[i]); }
    for( i = 1; i <= n; i++ ){ output(i, n); }
    return 0;
}
