- Time limit: 1.00 s
- Memory limit: 512 MB
Given an array of elements, your task is to divide into subarrays. The cost of each subarray is the square of the sum of the values in the subarray. What is the minimum total cost if you act optimally?
Input
The first input line has two integers and : the array elements and the number of subarrays. The array elements are numbered .
The second line has integers : the contents of the array.
Output
Print one integer: the minimum total cost.
Constraints
Example
Input:
8 3 2 3 1 2 2 3 4 1
Output:
110
Explanation: An optimal solution is , , , whose cost is .