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

#define NIL -1
#define MAX 251

int main(){
  int *node;
  int a, b, c, h;
  int i;

  scanf("%d", &h);

  node = malloc(sizeof(int)*h + 1);

  for(i = 0; i <= h; i++) node[i] = NIL;

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

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

