#include<stdio.h>
#define MAX 100005
#define NIL -1
int heap_size;
struct Node{
  int p; //parent
  int l; //left-child
  int r; //right sibiling
  int k;
};
struct Node T[MAX];

int main(void){
  int i;
  int d;
  scanf("%d", &heap_size);
  for ( i=1; i<=heap_size; i++ ) T[i].p=T[i].l=T[i].r=NIL;
  for ( i=1; i<=heap_size; i++ ){
    scanf("%d", &T[i].k);
  }
  for( i=1; i<=heap_size; i++ ){
    T[i].p=T[i/2].k;
    T[i].l=T[2*i].k;
    T[i].r=T[2*i+1].k;
  }
  for ( i=1; i<=heap_size; i++ ){
    printf("node %d: key = %d, ",i, T[i].k);
    if(T[i].p!=0) printf("parent key = %d, ", T[i].p);
    if(T[i].l!=0)printf("left key = %d, ",T[i].l); 
    if(T[i].r!=0)printf("right key = %d, ",T[i].r);
    printf("\n");
  }
  return 0;
}