SEGO: Sequential Subgoal Optimization for Mathematical Problem-Solving