CF1062A.A Prank

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array a1a_1 , a2a_2 , ..., ana_n of integers, such that 1a1<a2<<an1031 \le a_1 < a_2 < \ldots < a_n \le 10^3 , 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][1, 10^3] .

JATC wonders what is the greatest number of elements he can erase?

输入格式

The first line of the input contains a single integer nn ( 1n1001 \le n \le 100 ) — the number of elements in the array.

The second line of the input contains nn integers aia_i ( 1a1<a2<<an1031 \le a_1<a_2<\dots<a_n \le 10^3 ) — 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 00 .

输入输出样例

  • 输入#1

    6
    1 3 4 5 6 9
    

    输出#1

    2
  • 输入#2

    3
    998 999 1000
    

    输出#2

    2
  • 输入#3

    5
    1 2 3 4 5
    

    输出#3

    4

说明/提示

In the first example, JATC can erase the third and fourth elements, leaving the array [1,3,_,_,6,9][1, 3, \_, \_, 6, 9] . As you can see, there is only one way to fill in the blanks.

In the second example, JATC can erase the second and the third elements. The array will become [998,_,_][998, \_, \_] . Because all the elements are less than or equal to 10001000 , the array is still can be restored. Note, that he can't erase the first 22 elements.

In the third example, JATC can erase the first 44 elements. Since all the elements are greater than or equal to 11 , Giraffe can still restore the array. Note, that he can't erase the last 44 elements.

首页