Badge Pairs in a Row
A festival has a row of souvenir booths. The booth at position sells a badge of type .
A non-empty contiguous segment from booth to booth is called paired if no badge type appears exactly once inside it. More formally, for each integer type , let be the number of indices such that and . The segment is paired if, for every type , either or .
Find the maximum possible length of a paired segment. If there is no paired segment, the answer is .
Input
The input has exactly lines.
Line contains one integer (), the number of booths.
Line contains exactly integers (), where is the badge type at booth .
Output
Output exactly line.
The line contains one integer : the maximum value of over all paired segments. If no non-empty paired segment exists, output . The line must contain no other tokens.
Samples
Sample 1
Input
5 1 2 1 3 3
Output
2
The segment from booth to booth has two badges of type . No paired segment has length greater than .
Sample 2
Input
6 7 4 7 4 9 9
Output
6
In the whole line, each occurring type appears exactly times, so all booths can be chosen.