Problems
There are
For convenience, let the leftmost card be card
Each of the
By appropriately changing the numbers written on some of the
we want the numbers written on the cards to increase at a constant rate, decrease at a constant rate, or all be the same from left to right.
When changing the numbers on the cards, they can only be changed to integer values, and the number of changes must be minimized.
For example, suppose the cards are given as shown in the figure below.
In this case, if the number on card
It is also possible to make the numbers on all cards
Given the numbers written on each card in order from the leftmost card to the rightmost card,
find the minimum number of cards that must be changed to satisfy the condition.
Input
In the first line, the number of cards
In the second line, the numbers
[Constraints]
For all
Output
Print the answer on the first line.
Subtask
| # | Score | Condition |
|---|---|---|
| #1 | 3 | |
| #2 | 10 | The answer is less than or equal to |
| #3 | 20 | When the condition is satisfied by changing the minimum number of cards, it is guaranteed that there exists a case where the difference between the numbers written on adjacent cards is |
| #4 | 67 | No additional constraints. |
Example #1
4
1 2 2 4
1
Example #2
5
6 3 3 1 -1
2