Limits 1s, 512 MB

There is a guy named "Lucky" who is depressed now. His friend Jack knows why he is depressed. He has an array AA which contains nn numbers. He wants to find the largest sub-array where the first and the last element are same.

So Jack wants to help lucky. But he doesn't know anything about programming. That's why he comes to you as you are a great programmer in the world.

Find the size of the desired largest sub-array. A sub-array of an array is composed from a contiguous block of the original array's elements.

Input

The first line of the input will contain one integers nn (1n2×1051 ≤ n ≤ 2 \times 10^5), the size of the array.

The second line contains nn numbers: A1A_1, A2A_2, A3A_3, …, AnA_n (1Ai10181 ≤ A_i ≤ 10^{18}).

Output

Print the size of the desired largest sub-array.

Sample

InputOutput
6
1 2 3 4 1 5
5

Submit

Login to submit.

Statistics

56% Solution Ratio
Ahasan_1999Earliest, Mar '20
MR.Jukerburg11Fastest, 0.0s
artugal28_373Lightest, 3.0 MB
IshraqShortest, 172B
Toph uses cookies. By continuing you agree to our Cookie Policy.