#P6496. Minimum Modifications to Achieve a Palindromic Array
Minimum Modifications to Achieve a Palindromic Array
Minimum Modifications to Achieve a Palindromic Array
Given an array \( A \) with \( n \) elements (indexed from 1 to \( n \)), the array is called palindromic if for every integer \( i \) in \( [1, n] \), \( A_i = A_{n-i+1} \).
Mislav can modify the array by performing the following operation:
- Select two adjacent elements.
- Replace them with a single new element whose value is the sum of the two selected elements.
Your task is to determine the minimum number of modifications required to convert the given array into a palindromic array.
inputFormat
The first line contains an integer \( n \) (\(1 \leq n \leq 10^5\)) representing the number of elements in the array.
The second line contains \( n \) space-separated integers representing the elements of the array.
outputFormat
Output a single integer denoting the minimum number of modifications required to transform the array into a palindromic array.
sample
3
1 2 1
0