#P10902. [蓝桥杯 2024 省 C] 回文数组

[蓝桥杯 2024 省 C] 回文数组

Problem Description

When Xiao Lan is bored, he randomly generates an integer array of length nn. The ii-th number in the array is aia_i. He feels the randomly generated array is not very good-looking and wants to turn it into a palindrome array, that is, for any i[1,n]i \in [1,n], it satisfies ai=ani+1a_i = a_{n-i+1}.

In one operation, Xiao Lan may choose two adjacent numbers and increase both by 11 or decrease both by 11. He may also choose only one number and increase it by 11 or decrease it by 11. Find the minimum number of operations needed to make this array a palindrome array.

Input Format

The first line contains a positive integer nn.

The second line contains nn integers a1,a2,,ana_1, a_2, \cdots, a_n, 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 a1,a2a_1, a_2 by 11, becoming 2,3,3,42, 3, 3, 4.

In the next two operations, increase a1a_1 by 11, becoming 4,3,3,44, 3, 3, 4.

[Test Case Size and Conventions]

For 20%20\% of the test cases, 1n101 \le n \le 10.

For all test cases, 1n1051 \le n \le 10^5, 106ai106-10^6 \le a_i \le 10^6.

Translated by ChatGPT 5