Here's the key: smashing is just assigning + or. Signs to stones. When you smash and , the result is . If you trace through all smashes, the final result is .
So the problem becomes: partition stones into two groups to find the smallest absolute difference of their sums. If total sum is , and one group sums to , the difference is P. To reduce this, find the largest that's achievable. That's subset sum! Run boolean DP up to , find the largest true value, and compute .