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

#define NIL NULL

int parent(int i){
  return floor(i / 2);
}

int left(int i){
  return i * 2;
}

int right(int i){
  return (i * 2) + 1;
}

int main(){
  int h,i;
  int *k,*pk,*lk,*rk;

  scanf("%d",&h);

  k = malloc(sizeof(int)*(h+1));
  pk = malloc(sizeof(int)*(h+1));
  lk = malloc(sizeof(int)*(h+1));
  rk = malloc(sizeof(int)*(h+1));

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

  for(i = 1;i < h+1;i++){
    if(i != 1){
      pk[i] = k[parent(i)];
    }
    lk[i] = k[left(i)];
    rk[i] = k[right(i)];
  }

  for(i = 1;i < h+1;i++){
    printf("node %d: key = %d, ",i,k[i]);
    if(i != 1){
      printf("parent key = %d, ",pk[i]);
    }
    if(lk[i] != NIL && left(i) <= h){
      printf("left key = %d, ",lk[i]);
    }
    if(rk[i] != NIL && right(i) <= h){
      printf("right key = %d, ",rk[i]);
    }
    printf("\n");
  }

  return 0;
}