The best students of high level quality universities usually grab front row seats for better listening to the lectures.
However, since college students usually do not wake up early, the bad custom of going to the classroom one night earlier to take a seat with a book is prevalent.
To simplify the problem, suppose our seats are a straight line with coordinates 0 ~ n+1 expanded.
In the night before the early eight, the moon is dark and windy, the air is only cold winter wind in the whistling, before and after there are n students,
sneaking to the classroom, where the ith student with his book to occupy the coordinates of xi's position, because sitting on the edge of the most can
not see the board clearly, so they will only take up the middle of the position of the 1 ~ n. 【The night is too too dark, so the students who take up the
position of the position of the position of the students to see the position of the things, so there could be more than one placeholder book in one spot】.
The next morning, in order to go to the front row of the lucid not confused at 6:00 a.m. out of bed, rushed to the classroom to see an empty, but full of books classroom,
the front row! NO! Position up!!! The warm winter sun is so stinging and cold! She was so angry that she wanted to give a lesson to these bad occupation behavior.
Xilibala intended to let the books occupy as little as possible, but not too obvious, for the position of xi occupation book, Xilibalacan move it to xi-1 or xi +1 position,
or can also be retained in the position of xi, in order not to be detected, each book Xilibala only moved once! Multiple books in the same position can be placed in different
positions,e.g., 3 books in position xi = 3 can be placed in positions 2, 3, 4 respectively.
We stipulate that for all placeholder books at positions 1 <= xi <= n, Clearly Not Confused can place the placeholder book at positions with coordinates 0 and n+1
(if the placeholder book is at 1 or n respectively).
For example, the initial position of the placeholder is x=[1,2,4,4]. The final position can be [1,3,3,4], [0,2,3,3], [2,2,5,5], and so on....
Xilibala wants you to help her figure out what is the minimum number of space occupied by these n placeholder books through her series of optimal magic operation?
Enter a number n, indicating that there are n students to place books in the evening;
Enter n numbers in the second line, x1,x2... .. xn ( 1<=xi<=n ) which position is occupied by n students' books.
Figure out what is the minimum number of space occupied by these n placeholder books through her series of optimal magic operation?
2 1 2
1