The maximal section algorithm in the Monte Carlo method