- TopCoder solution with dynamic programming solution
- Choose a star x other than the very first star and the very last star.
- The x-th star disappears.
- This generates weight[x-1] * weight[x+1] units of energy.
- We decrease n and relabel the stars 0 through n-1 from the left to the right.