//
//  main.c
//  A
//
//  Created by s1262004 on 2019/07/12.
//  Copyright © 2019 s1262004. All rights reserved.
//

#include <stdio.h>

#define H 255
#define parent(x) x >> 1
#define left(x) x << 1
#define right(x) (x << 1) + 1

int n; //A.length
int node[H];
int heapSize;

void buildMaxHeap();
void maxHeapify(int);
void swap(int, int);
void printNode(int);

int main(int argc, const char * argv[]) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &node[i]);
    for (int i = 1; i <= n; i++) printNode(i);
    return 0;
}

void printNode(int i){
    printf("node %d: ", i);
    printf("key = %d, ", node[i]);
    if (i != 1) printf("parent key = %d, ", node[parent(i)]);
    if (left(i) <= n) printf("left key = %d, ", node[left(i)]);
    if (right(i) <= n) printf("right key = %d, ", node[right(i)]);
    printf("\n");
}


