#include<stdio.h>

void print(void);
int n,A[251];
int main(){
  int i,k;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&k);
    A[i]=k;
  }
  print();
  return 0;
}

void print(){
  int i;
  if(A[1]==NULL){
    printf("node 1: key = %d, \n",A[1]);
  }else if(A[2]==NULL){
    printf("node 1: key = %d, right key = %d, \n",A[1],A[2]);
  }else{
    printf("node 1: key = %d, left key = %d, right key = %d, \n",A[1],A[2],A[3]);
    for(i=2;i<=n;i++){
      if(A[2*i]==NULL){
	printf("node %d: key = %d, parent key = %d, \n",i,A[i],A[i/2]);
      }else if(A[(2*i)+1]==NULL){
	printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,A[i],A[i/2],A[2*i]);
      }else{
	printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,A[i],A[i/2],A[2*i],A[2*i+1]);
      }
    }
  }
}


