/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: Ivan
 *
 * Created on July 19, 2018, 1:58 AM
 */

#include <stdio.h>
#include <stdlib.h>
#define MAX 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(int argc, char** argv) {
    int H, T[MAX+1];
    scanf("%d", &H);
    
    for (int i = 1; i <= H; ++i) scanf("%d", &T[i]);
    for (int i = 1; i <= H; ++i) 
    {
        printf("node %d: key = %d,", i, T[i]);
        if (parent(i) >= 1) printf("parent key = %d,", T[parent(i)]);
        if (left(i) <= H) printf("left key = %d,", T[left(i)]);
        if (right(i) <= H) printf("right key = %d,", T[right(i)]);
        printf("\n");    
    }
    return (EXIT_SUCCESS);
}


