#include<stdio.h>
#define M 250

int parent(int i){
    return i/2;
}
int Left(int i){
    return 2*i;
}
int Right(int i){
    return 2*i+1;
}

int main(void){
    int i;
    int n;
    int heap[M];
    scanf("%d",&n);
    for(i=1;i<n+1;i++){
        scanf("%d",&heap[i]);
    }
    
    for(i=1;i<n+1;i++){
        if(i==1)printf("node %d: key = %d, ",i,heap[i]);
        else if(i>1)printf("node %d: key = %d, parent key = %d, ",i,heap[i],heap[parent(i)]);
        
        if(Left(i)<=n)printf("left key = %d, ",heap[Left(i)]);
        if(Right(i)<=n)printf("right key = %d, ",heap[Right(i)]);
        printf("\n");
            
            }
                             return 0;
}