#include<stdio.h>
#define N 251
#define NIL -1
typedef struct{
  int k, p, l, r;
} node;

node A[N];

int main(){
  int hs, i;
  scanf("%d", &hs); 
  for(i = 1; i <= N; i++){
    A[i].k = NIL;
    A[i].p = NIL;
    A[i].l = NIL;
    A[i].r = NIL;
  }
  for(i = 1; i <= hs; i++){
    scanf("%d", &A[i].k);
  }
  for(i = 1; i <= hs; i++){
    if(i != 1) A[i].p = A[i/2].k;
    if(A[2*i].k != NIL) A[i].l = A[2*i].k;
    if(A[2*i+1].k != NIL) A[i].r = A[2*i+1].k;
  }
  for(i = 1; i <= hs; i++){
    printf("node %d: key = %d, ", i, A[i].k);
    if(A[i].p != NIL) printf("parent key = %d, ", A[i].p);
    if(A[i].l != NIL) printf("left key = %d, ", A[i].l);
    if(A[i].r != NIL) printf("right key = %d, ", A[i].r);
    printf("\n");
  }
  return 0;
}