#include <stdio.h>

#define N 10000
#define Nil -1

typedef struct{
  int key,p,l,r;
    }Node;

Node T[N];
int n;

/*void max_heapify(Node,int)*/;
void print(int);

int main(){
  int i,l,r;

  scanf("%d",&n);
  for(i=1;i<=n;i++)
    T[i].p = T[i].l = T[i].r = Nil;

  for(i=1;i<=n;i++)
    scanf("%d", &T[i].key);

  for(i=n;i>1;i--){
    T[i].p = i/2;   
    if(i == 2*T[i].p)  T[T[i].p].l = i;    
    else if(i == 2*T[i].p + 1)T[T[i].p].r =i; 
  }

  for(i=1;i<=n;i++)
    print(i);

  return 0;
}



void print(int u){
 
  printf("node %d: key = %d,",u,T[u].key);

  if(T[u].p != Nil)printf(" parent key = %d,",T[T[u].p].key);
  if(T[u].l != Nil)printf(" left key = %d,",T[T[u].l].key);
  if(T[u].r != Nil) printf(" right key = %d,", T[T[u].r].key);
  printf("\n");
}