#include<stdio.h>

#define H 250

typedef struct{
  int r;
  int l;
  int p;
  int k;
}T;

int parent(int);
int right(int,int);
int left(int,int);

int main(){
    
    T tree[H];
    int i,h,pid,rid,lid;
    
    scanf("%d",&h);
    
    for(i=1;i<=h;i++){
      tree[i].r=-1;
      tree[i].l=-1;
      tree[i].p=-1;
    }
    
    for(i=1;i<=h;i++){
        scanf("%d",&tree[i].k);
    }
    
    for(i=1;i<=h;i++){
        
        pid=parent(i);
        if(pid!=-1) tree[i].p=pid;
        rid=right(i,h);
        if(rid!=-1) tree[i].r=rid;
        lid=left(i,h);
        if(lid!=-1) tree[i].l=lid;
    
    }
    
    for(i=1;i<=h;i++){
        printf("node %d: ",i);
        printf("key = %d, ",tree[i].k);
        if(tree[i].p!=-1){
            printf("parent key = %d, ",tree[tree[i].p].k);
        }
        
        if(tree[i].l!=-1){
            printf("left key = %d, ",tree[tree[i].l].k);
        }
        
        if(tree[i].r!=-1){
            printf("right key = %d, ",tree[tree[i].r].k);
        }
        
        printf("\n");
    }
    
    return 0;
}

int parent(int i){
    int pid;
    
    pid=i/2;
    
    if(pid<=0) pid=-1;
    
    return pid;
    
}

int right(int i,int h){
    int rid;
    
    rid=2*i+1;
    if(rid>h) rid=-1;
    
    return rid;

}

int left(int i,int h){
    int lid;
    
    lid=2*i;
    if(lid>h) lid=-1;
    
    return lid;

}

