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

int main(){
  int H,i;
  Tree *T;
  scanf("%d",&H);
  T=(Tree*)malloc(sizeof(Tree)*H);
  for(i=0;i<H;i++){
    T[i].key=-1;
    T[i].parent=-1;
    T[i].left=-1;
    T[i].right=-1;
  }
  for(i=0;i<H;i++){
    scanf("%d",&T[i].key);
    T[i].parent=(i+1)/2-1;
    if(2*i+1<H){
      T[i].left=2*i+1;
      if(2*i+2<H)
	T[i].right=2*i+2;
    }
  }
  for(i=0;i<H;i++){
    printf("node %d: key = %d, ",i+1,T[i].key);
    if(T[i].parent!=-1)
      printf("parent key = %d, ",T[T[i].parent].key);
    if(T[i].left!=-1)
      printf("left key = %d, ",T[T[i].left].key);
    if(T[i].right!=-1)
      printf("right key = %d, ",T[T[i].right].key);
    printf("\n");
  }
}