After reading an article on the Longest Increasing Subsequence problem, your friend Lucas is interested in other problems involving increasing subsequences.
Recently, he has started asking you about increasing subsequences with large 'gaps'. Given a sequence
Note that Lucas does not need the sequence to be strictly increasing. Specifically, he is fine if
In particular, given a sequence of
Unfortunately, when he wrote down his sequence
If no valid -1
and if the set of valid Infinity
.
Constraints
Subtask 1 [20%]
Subtask 2 [30%]
Subtask 3 [50%]
No additional constraints.
Input Specification
The first line contains two integers:
The second line contains
Output Specification
Output the maximum possible subsequence gap, or -1
if no such subsequence exists.
If the maximum possible gap is unbounded, output Infinity
.
Sample Input 1
10 10
4 -1 -1 23 -1 54 -1 -1 63 -1
Sample Output 1
3
Sample Input 2
10 5
4 -1 74 23 643 54 33 5 63 -1
Sample Output 2
35
Sample Input 3
10 6
-1 5 -1 4 -1 3 -1 2 -1 1
Sample Output 3
Infinity
Sample Input 4
10 6
1 5 2 4 3 3 4 2 5 1
Sample Output 4
0
Sample Input 5
10 7
1 5 2 4 3 3 4 2 5 1
Sample Output 5
-1
Comments