Submit solution

Points: 100
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Problem Statement

Josh loves eating mochi icecream from the Coles freezer section. This freezer section can be modeled as an array of n integers, where the value of the i-th integer represents the flavour of mochi it is. Although he loves this mochi, he knows that if he eats two of the same flavour he will perish! Furthermore, he can only buy a contininous section of this array.

Knowing these facts, what is the biggest amount of mochi Josh can eat?

Input Format

The first line of input will be a single n. The next line will contain n integers, representing the type of each mochi.

Output Format

The output should consist of a single line, the maximum number of mochis (mochii?) he can eat.

Sample Input 1

7
1 1 2 1 3 1 4

Sample Output 1

3

Sample Explanation

One optimal solution would be (2,1,3). Another would be (3,1,4). Both are length 3. Note that (1,3,1) is not a valid solution as it contains the first type of mochi twice.

Constraints

1 \le n \le 1e5


Comments

There are no comments at the moment.