#include<stdio.h>

int n;

typedef struct node{
  int key;
  long int parent;
  int left;
  int right;
}Node;

int parent(i){
  if(i==1) return -1;
  else return i/2;
}

int left(i){
  if(2*i > n) return -1;
  else return 2*i;
}

int right(i){
  if(2*i+1 > n) return -1;
  else return 2*i+1;
}
	       

int main(){

  int i;
  scanf("%d",&n);

  Node H[n+1];

  for(i=1;i<=n;i++){
    scanf("%d",&H[i]);
    H[i].parent = H[i].left = H[i].right = -1;
  }

  for(i=1;i<=n;i++){
    if(parent(i)!=-1) H[i].parent = H[parent(i)].key;
    if(left(i)!=-1) H[i].left = H[left(i)].key;
    if(right(i)!=-1) H[i].right = H[right(i)].key;
  }

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

