/*s1190073  Rina Sato
  File name: prog9a.c
  This is a heap program.
*/

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

#define MAX 250

struct Node{
  int p;
  int l;
  int r;
};

struct Node T[MAX];

int Parent(int i){
  return i/2;
}
int Left(int i){
  return 2*i;
}
int Right(int i){
  return 2*i+1;
}

int main(void){
  int heap_size,i,key[MAX],left[MAX],right[MAX];

  scanf("%d",&heap_size);

  for(i = 1 ; i <= heap_size ; i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }

  for(i = 1 ; i <= heap_size ; i++){
    scanf("%d",&key[i]);
  }
  
  for(i = 1 ; i <= heap_size ; i++){
    if(i > 1){
      T[i].p = key[Parent(i)];
    } 
    
    left[i] = Left(i);
    if(left[i] <= heap_size){
      T[i].l = key[left[i]]; 
    }
    
    right[i] = Right(i);
    if(right[i] <= heap_size){
      T[i].r = key[right[i]];
    } 
  }
  
  for(i = 1 ; i <= heap_size ; i++){
    printf("node %d: key = %d, ",i,key[i]);
    
    if(i > 1){
      printf("parent key = %d, ",T[i].p);
    }
    if(left[i] <= heap_size){
      printf("left key = %d, ",T[i].l); 
    }
    if(right[i] <= heap_size){
      printf("right key = %d, ",T[i].r);
    } 
    printf("\n");
  }
  return 0;
}