Problem1813--最长连续序列(动规课程B)(4)

1813: 最长连续序列(动规课程B)(4)

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

n 个数的数列中, 删除其中的一些数, 剩下的数如果是 a, a+1, a+2, a+3,…a+x , 就称为是一段连续的序列。 求长度(x+1)的最大值。

Input

第一行一个数 n, 范围[1..1000]
第二行
n 整数,范围[1..10000]

Output

一个整数, 最大的长度。

Sample Input Copy

8
7 9 3 8 4 5 20 6

Sample Output Copy

4

HINT

解释: 最长的序列是 3 4 5 6,长度 6-3+1=4

Source/Category