#P10902. Make Palindrome Array
Make Palindrome Array
Make Palindrome Array
You are given an integer n and an array of n integers \(a_1, a_2, \dots, a_n\). The array is considered a palindrome if for every index \(i\) (\(1 \le i \le n\)) the following holds:
\(a_i = a_{n-i+1}\)
You can perform the following operations:
- Single-element operation: Select one element and add or subtract 1.
- Adjacent pair operation: Select two adjacent elements and add or subtract 1 from both simultaneously.
Determine the minimum number of operations required to transform the given array into a palindrome array.
inputFormat
The first line contains a single integer n (the length of the array).
The second line contains n space-separated integers \(a_1, a_2, \dots, a_n\).
outputFormat
Output a single integer representing the minimum number of operations required to turn the array into a palindrome.
sample
3
1 2 3
2