题库练习 A Prank
← 上一题 下一题 →

A12085 | A Prank

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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

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

输入格式

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

The second line of the input contains $n$ integers $a_i$ ( $1 \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 $0$ .

输入输出样例

输入 #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
C++ 编辑器
输入
输出