#include<stdio.h>
 typedef struct{
   int id;
  int key;
  int leftKey;
  int rightKey;
  int parentKey;
}heap;

void insert(int, int);
void print(int, int);
heap Heap[251];
int A[251];

main(){
  int H, i;
  scanf("%d ", &H);
  for(i = 1; i <= H; i++){
    scanf(" %d", &A[i]);
  }
  for(i = 1; i <= H; i++){
    insert(i, H);
  }
  for(i = 1; i <= H; i++){
    print(i, H);
  }
  return 0;
}

void insert(int id, int H){
  Heap[id].id = id;
  Heap[id].key = A[id];
  if(id/2 > 0)    Heap[id].parentKey = A[id/2];
  if(id*2 <= H)   Heap[id].leftKey = A[id*2];
  if(id*2+1 <= H) Heap[id].rightKey = A[id*2+1]; 
}

void print(int id, int H){
   printf("node %d: key = %d, ", id, Heap[id].key);
   if(id/2 > 0)    printf("parent key = %d, ", Heap[id].parentKey);
   if(id*2 <= H)   printf("left key = %d, ", Heap[id].leftKey);
   if(id*2+1 <= H) printf("right key = %d, " , Heap[id].rightKey);
   printf("\n");
 }