Calculate the minimum distance from the start to the goal with passing all the checkpoints.