#include <stdio.h>
#define N 251
#define NIL 0

int A[N];

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

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

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

int main()
{
  int i,H;
  for(i = 0; i < N; i++) A[i] = NIL;
  scanf("%d",&H);
  for(i = 1; i <=H; i++){
    scanf("%d",&A[i]);
  }
  for(i = 1; i <= H ;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(A[parent(i)] == NIL) printf("left key = %d, right key = %d, \n",A[left(i)],A[right(i)]);
    else if(A[right(i)] != NIL && A[left(i)] != NIL) printf("parent key = %d, left key = %d, right key = %d, \n",A[parent(i)],A[left(i)],A[right(i)]);
    else if(A[right(i)] == NIL && A[left(i)] != NIL) printf("parent key = %d, left key = %d, \n",A[parent(i)],A[left(i)]);
    else printf("parent key = %d, \n",A[parent(i)]);
  }
    return 0;
}
  

