#include <stdio.h>
#include <stdlib.h>
 
int main(){
  int n,a,i;
  int id=1;
  int *heap;
 
  scanf("%d", &n);
  heap = (int *)malloc(sizeof(int)*(n+1));
  for(i=0; i<n; i++){
    scanf("%d", &a);
    heap[i + 1] = a;
  }
  for(; id<=n; id++){
    printf("node %d: ", id);
    printf("key = %d, ", heap[id]);
    if(id/2 > 0)
      printf("parent key = %d, ", heap[id/2]);
    if(id*2 <= n)
      printf("left key = %d, ", heap[id*2]);
    if(id*2+1 <= n)
      printf("right key = %d, ", heap[id*2+1]);
    putchar('\n');
  }
  return 0;