#include<stdio.h>

int main(){
  int h,i,heap[251];
  scanf("%d",&h);
  for(i=1;i<h+1;i++) scanf("%d",heap+i);
  for(i=1;i<h+1;i++){
    printf("node %d: key = %d, ",i,heap[i]);
    if(i!=1) printf("parent key = %d, ",heap[i/2]);
    if(i*2<=h) printf("left key = %d, ",heap[i*2]);
    if(i*2+1<=h) printf("right key = %d, ",heap[i*2+1]);
    printf("\n");
  }
  return 0;
}

