#include <stdio.h>
struct node{
  int key;
  int parent;
  int left;
  int right;
};

int main(){
  int h, i;
  scanf("%d", &h);
  struct node A[h+1];
  for(i=1;i<h+1;i++){
    scanf("%d", &A[i].key);
    A[i].parent=0;
    A[i].left=0;
    A[i].right=0;
  }
  for(i=1;i<h+1;i++){
    if(i>=2) A[i].parent = A[i/2].key;
    if((2*i)<=h) A[i].left = A[(2*i)].key;
    if((2*i+1)<=h) A[i].right = A[(2*i+1)].key;
  }
  for(i=1;i<h+1;i++){
    printf("node %d: key = %d,", i, A[i].key);
    if(A[i].parent>0) printf(" parent key = %d,", A[i].parent);
    if(A[i].left>0)   printf(" left key = %d,",   A[i].left);
    if(A[i].right>0)  printf(" right key = %d,",  A[i].right);
    printf(" \n");
  }
  return 0;
}
