#include <stdlib.h>
#include <stdio.h>

void allprint(int*,int);

int main(){
    int n;
    int *heap;

    scanf("%d",&n);
    heap=malloc(sizeof(int)*n+1);

    for(int i=1;i<=n;i++){
        scanf("%d",&heap[i]);
    }

    allprint(heap,n);

    return 0;
}

void allprint(int* heap,int max){
    int parent;
    int right;
    int left;

    for(int i=1;i<=max;i++){
        parent=i/2;
        right=i*2+1;
        left=i*2;
        printf("node %d: key = %d, ",i,heap[i]);
        if(parent>0){
            printf("parent key = %d, ",heap[parent]);
        }
        if(left<=max&&right<=max){
            printf("left key = %d, right key = %d, \n",heap[left],heap[right]);
        }
        else if(left>max&&right<=max){
            printf("right key = %d, \n",heap[right]);
        }
        else if(right>max&&left<=max){
            printf("left key = %d, \n",heap[left]);
        }
        else{
            printf("\n");
        }
    }
}

