A Prank
Hazrat Ali
JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array a1, a2, ..., an of integers, such that 1≤a1<a2<…<an≤103, and then went to the bathroom.
JATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range [1,103].
JATC wonders what is the greatest number of elements he can erase?
The first line of the input contains a single integer n (1≤n≤100) — the number of elements in the array.
The second line of the input contains n integers ai (1≤a1<a2<⋯<an≤103) — the array written by Giraffe.
Print a single integer — the maximum number of consecutive elements in the array that JATC can erase.
If it is impossible to erase even a single element, print 0.
6
1 3 4 5 6 9
2
3
998 999 1000
2
5
1 2 3 4 5
4
Solution