#P10902. [蓝桥杯 2024 省 C] 回文数组
[蓝桥杯 2024 省 C] 回文数组
Problem Description
When Xiao Lan is bored, he randomly generates an integer array of length . The -th number in the array is . He feels the randomly generated array is not very good-looking and wants to turn it into a palindrome array, that is, for any , it satisfies .
In one operation, Xiao Lan may choose two adjacent numbers and increase both by or decrease both by . He may also choose only one number and increase it by or decrease it by . Find the minimum number of operations needed to make this array a palindrome array.
Input Format
The first line contains a positive integer .
The second line contains integers , separated by one space between adjacent integers.
Output Format
Output one line containing one integer, representing the answer.
4
1 2 3 4
3
Hint
[Sample Explanation]
In the first operation, increase by , becoming .
In the next two operations, increase by , becoming .
[Test Case Size and Conventions]
For of the test cases, .
For all test cases, , .
Translated by ChatGPT 5