#D5458. Bumpy Array
Bumpy Array
Bumpy Array
problem
Given the sequence of length . The item in is . You can do the following for this sequence:
- $ 1 \ leq i \ leq N --Choose the integer i that is 1 $. Swap the value of with the value of .
Find the minimum number of operations required to make a sequence of bumps.
A sequence of length that satisfies the following conditions is defined as a sequence of irregularities.
- For any that satisfies , or . Intuitively, increase, decrease, increase ... (decrease, like $ 1, \ 10, \ 2, \ 30, \ \ dots (10, \ 1, \ 30, \ 2, \ \ dots) $ It is a sequence that repeats increase, decrease ...).
output
Output the minimum number of operations required to make a sequence of bumps. Also, output a line break at the end.
Example
Input
5 1 2 3 4 5
Output
2
inputFormat
outputFormat
output
Output the minimum number of operations required to make a sequence of bumps. Also, output a line break at the end.
Example
Input
5 1 2 3 4 5
Output
2
样例
5
1 2 3 4 5
2