#include<stdio.h>

#define max 251

int main(){
  int i;
  int heap[max],heapsize,leftN,rightN;

  scanf("%d",&heapsize);
  for(i=1;i<=heapsize;i++){
    scanf("%d",&heap[i]);
  }
  
  for(i=1;i<=heapsize;i++){
    printf("node %d: key = %d, ",i,heap[i]);
    if(i>1){
      printf("parent key = %d, ",heap[parent(i)]);
    }
    leftN=left(i);
    rightN=right(i);
    if(leftN<=heapsize){
      printf("left key = %d, ",heap[leftN]);
    }
    if(rightN<=heapsize){
      printf("right key = %d, ",heap[rightN]);
    }
    printf("\n");
  }

  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}