cswork / OAOpen practice workspace

Akuna CapitalOA #19

An Evening of Movies

Estimated MediumJudge-ready

Topics (AI-labelled)HashingIn-place Arrays

Pick movies from the library and arrange them in any order; the runtimes of adjacent movies must be equal or increase by exactly 1 minute, and no movie may be watched twice. Find the maximum number of movies that can be watched.

Input

The first line contains n; the second line contains n positive integers runtime[i]. The original gives no value bounds; this site adds 1≤n≤100000, 1≤runtime[i]≤10^9.

Output

Output the maximum number of movies that can be watched.

Example 1

Input:

5
8 4 5 7 4

Output:

3

Example 2

Input:

3
1 1 1

Output:

3

Example 3

Input:

5
1 2 2 3 5

Output:

4

Editorial

Loading solution…