#include<stdio.h>
#define MAX 250
int heap[MAX];

int main(){
  int i,H,t;
  scanf("%d\n", &H);

  for(i=1;i<=H;i++) scanf("%d",&heap[i]);

  for(i=1;i<=H;i++){
    printf("node %d: key = %d,",i,heap[i]);
    if(i>1) printf("parent key = %d,",heap[parent(i)]);
    if(left(i)<=H) printf("left key = %d,",heap[left(i)]);
    if(right(i)<=H) printf("right key = %d,",heap[right(i)]);
    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;}



