#include <stdio.h>
#define NIL -1

int n;

int getparent(int i){
    i /= 2;
    if(i < 1) return NIL;
    else return i;
}

int getleft(int i){
    i *= 2;
    if(i > n) return NIL;
    else return i;
}

int getright(int i){
    i = 2*i+1;
    if(i > n) return NIL;
    else return i;
}

int main(){
    int i,parent,left,right,key[250];
    
    scanf("%d",&n);
    for(i=1; i<=n; i++){
    scanf("%d",&key[i]);
    }
        
        for(i=1; i<=n; i++){
      parent = getparent(i);
      left = getleft(i);
      right = getright(i);
     
     printf("node %d: key = %d, ",i,key[i]);
            
            if(parent != NIL)
            printf("parent key = %d, ",key[parent]);
            if(left != NIL)
            printf("left key = %d, ",key[left]);
            if(right != NIL)
            printf("right key = %d, ",key[right]);
             printf("\n");
        }
    return 0;
}