Do Geese See God? Or, Was It A Rat I Saw? Nevermind the geese or rats, this is just an unnecessary introduction to showcase Mislav's love of palindromes. Help him solve the following task!
Let
Mislav can modify the array in the following way: in a single move, he chooses two adjacent elements of that array and replaces them with their sum. Notice that the number of elements in the array is going to decrease by
Input Specification
The first line of input contains the integer
The following line contains
Output Specification
Output the minimal number of moves it takes to transform the original array to a palindromic one, given the rules from the task.
Scoring
In test cases worth
In test cases worth
Sample Input 1
3
1 2 3
Sample Output 1
1
Explanation for Sample Output 1
1 2 3 → 3 3
Sample Input 2
5
1 2 4 6 1
Sample Output 2
1
Explanation for Sample Output 2
1 2 4 6 1 → 1 6 6 1
Sample Input 3
4
1 4 3 2
Sample Output 3
2
Explanation for Sample Output 3
1 4 3 2 → 5 3 2 → 5 5
Comments