#include<stdio.h>

#define Max 250

typedef struct{
  int key;
  int parent;
  int left;
  int right;
}Node;

int main(){
  int i, H;
  Node T[Max];

  scanf("%d",&H);
  for(i = 1; i <= H; i++){
    T[i].parent = NULL;
    T[i].left = NULL;
    T[i].right = NULL;
  }
  for(i = 1; i <= H; i++){
    scanf("%d",&T[i].key);
    if(i > 1) T[i].parent = T[i / 2].key;
  }
  for(i = 1; i <= H; i++){
    T[i].left = T[2 * i].key;
    if(2 * i > H) T[i].left = NULL;
    T[i].right = T[2 * i + 1].key;
    if(2 * i + 1> H) T[i].right = NULL;
  }

  for(i = 1; i <= H; i++){
    printf("node %d: key = %d, " ,i, T[i].key);
    if(T[i].parent != NULL) printf("parent key = %d, ", T[i].parent);
    if(T[i].left != NULL) printf("left key = %d, ", T[i].left);
    if(T[i].right != NULL) printf("right key = %d, ", T[i].right);
    printf("\n");
  }

  return 0;
}