#include<stdio.h>
typedef struct{
  int key;
  int left;
  int right;
  int parent;
  int id;
}tree;
int main(){
  int i,j,k,num1,n;
  scanf("%d",&n);
  tree heap[n+1];
  for(i=1;i<=n;i++){
    scanf("%d",&heap[i].key);
    heap[i].id=i;
    heap[i].parent=heap[i].right=heap[i].left=NULL;
  }
  for(i=1;i<=n;i++){
    if(i/2>0)
      heap[i].parent=heap[i/2].key;
    if(i*2>n)continue;
    if(heap[2*i].key!=NULL)
      heap[i].left=heap[2*i].key;
    if(i*2+1>n)continue;
    if(heap[2*i+1].key!=NULL) 
      heap[i].right=heap[2*i+1].key;
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",heap[i].id,heap[i].key);
    if(heap[i].parent!=NULL)
      printf("parent key = %d, ",heap[i].parent);
    if(heap[i].left!=NULL)
      printf("left key = %d, ",heap[i].left);
    if(heap[i].right!=NULL)
      printf("right key = %d, ",heap[i].right);
    printf("\n");
  }
  return 0;
}

