#P1420. 最长连号

最长连号

Description

Given a sequence of positive integers of length nn, output the length of the longest consecutive sequence in the sequence.

“Consecutive” means consecutive natural numbers in increasing order that appear in the sequence.

Input Format

The first line contains an integer nn.

The second line contains nn integers aia_i, separated by spaces.

Output Format

Output one integer: the number of elements in the longest consecutive sequence.

10
1 5 6 2 3 4 5 6 8 9
5


Hint

Constraints

For 100%100\% of the testdata, it is guaranteed that 1n1041 \leq n \leq 10^4, 1ai1091 \leq a_i \leq 10^9.

Translated by ChatGPT 5