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

struct Node{
  int id,K,parent,left,right;
};

struct Node *T;

int main(){
  int H,i;

  scanf("%d",&H);
  T = (struct Node *)malloc(sizeof(struct Node)*(H+1));
  for(i=1; i<=H; i++){
    T[i].id = i;
    scanf("%d",&T[i].K);
  }
  for(i=1; i<=H; i++){
    printf("node %d: key = %d, ",T[i].id,T[i].K);
    if(i != 1){
      T[i].parent = T[i/2].K;
      printf("parent key = %d, ",T[i].parent);
    } 
    if(2*i <= H) {
      T[i].left = T[2*i].K;
      printf("left key = %d, ",T[i].left);
    }
    if((2*i+1) <= H) {
      T[i].right = T[2*i+1].K;
      printf("right key = %d, ",T[i].right);
    }
    printf("\n");
  }
  return 0;
}