#include<stdio.h>
#include<stdlib.h>
typedef struct node{
  int key;
  struct node *p, *l, *r;
}T_node;
int main(){
  int n;
  scanf("%d", &n);
  T_node *heap[n + 1];
  int i;
  for(i = 1; i <= n; i++){
    heap[i] = (T_node *)malloc(sizeof(T_node));
    heap[i]->p = heap[i]->l = heap[i]->r = NULL;
    scanf("%d", &(heap[i]->key));
    if(i /2){
      heap[i]->p = heap[i / 2];
      if(i % 2)
	heap[i / 2]->r = heap[i];
      else
	heap[i / 2]->l = heap[i];
    }
  }
  for(i = 1; i <= n; i++){
    printf("node %d: key = %d, ", i, heap[i]->key);
    if(heap[i]->p != NULL)
      printf("parent key = %d, ", heap[i]->p->key);
    if(heap[i]->l != NULL)
      printf("left key = %d, ", heap[i]->l->key);
    if(heap[i]->r != NULL)
      printf("right key = %d, ", heap[i]->r->key);
    printf("\n");
  }
  for(i = n; i > 0; i--)
    free(heap[i]);
  return 0;
}