Split n soldiers into contiguous groups. Group value = a⋅x2+b⋅x+c where x is sum of strengths in group. dp[i] = max value for first i soldiers.
Transition: dp[i]=maxj<i(dp[j]+f(Si−Sj)) where S is prefix sum. Expand f(Si−Sj)=a(Si−Sj)2+b(Si−Sj)+c. Separate terms by i and j. Result: linear in Si with slope depending on j. Apply CHT. Handle max instead of min by negating.