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

typedef struct{
  int k;
  int pk;
  int lk;
  int rk;
}Heap;

int main(){
  Heap A[251];
  int H;
  int i;

  scanf("%d", &H);
  if(250 < H)
    exit(0);

  for(i = 1; i <= H; i++){
    scanf("%d", &A[i].k);
    if(A[i].k < -2000000000 || 2000000000 < A[i].k)
      exit(1);
    A[i].pk = NULL;
    A[i].lk = NULL;
    A[i].rk = NULL;
  }
    
  for(i = 1; i <= H; i++){
    if(i == 1){
      if(i * 2 <= H && A[i*2].k != NULL)
	A[i].lk = A[i*2].k;
      if(i * 2 + 1 <= H && A[i*2+1].k != NULL)
	A[i].rk = A[i*2+1].k;
    }
    else{
      A[i].pk = A[i/2].k;
      if(i * 2 <= H && A[i*2].k != NULL)
	A[i].lk = A[i*2].k;
      if(i * 2 + 1 <= H && A[i*2+1].k != NULL)
	A[i].rk = A[i*2+1].k;
    }
  }

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

  return 0;
}