#include <stdio.h>
#define NUM 250

struct kk {
  int key;
  int parent;
  int right;
  int left;
};

struct kk A[NUM];

int main()
{
  int H,i;
  scanf("%d",&H);

  for(i = 1;i <= H;i++){
    scanf("%d",&A[i].key);
    A[i].parent = A[i/2].key;
    if(i%2 == 0) A[i/2].left = A[i].key;
    if(i%2 == 1) A[i/2].right = A[i].key;
  }


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

  return 0;
}
  

