734. Greedy Adarsh

0

Hard

Adarsh is an avid reader who loves going to the library. The library has a collection of N books, each with a unique ID. Some books may have the same ID. Adarsh wants to read the books in consecutive order based on their IDs. Help Adarsh determine the maximum number of books he can read in consecutive order from the library. Solve this problem with a time complexity of O(n).

Input Format

The first line of input contains an integer N, representing the number of books in the library. The second line contains N integers, each representing the ID number of a book.

Output Format

Print the maximum number of consecutive book IDs in the library.

Example

Input

7 10 10 1 5 3 7 4

Output

3

Constraints

0 <= N <= 10^5
-10^9 <=arr[i]<= 10^9
Loading...

View Submissions

Console