"And when you think that they actually made the tests for joingraf..."
Task
After conducting the tests for the joingraph problem at the last RoAlgo contest, the committee realized that a special problem was still needed. After extensive discussions, the following problem was created:
Given arrays of numbers, find the length of the longest subarray that contains at most distinct numbers. An example of such a subarray is: .
Input data
The first line of the input contains the number . For each test, the first line contains , representing the number of numbers. The second line contains the numbers.
Output data
For each test, print the maximum length of a subarray with at most distinct numbers.
Constraints and clarifications
- The sum of the lengths of all arrays does not exceed .
# | Points | Constraints |
---|---|---|
1 | 0 | Example |
2 | 14 | |
3 | 22 | |
4 | 38 | |
5 | 26 | No additional constraints |
Example
stdin
5
10
1 4 7 4 2 4 7 3 2 3
8
1 2 4 1 5 3 1 2
10
6 8 9 1 8 5 4 6 3 2
6
1 1 1 2 2 2
12
1 5 8 3 2 5 7 4 9 5 7 4
stdout
6
4
4
6
3
Explanation
The subarray 4 7 4 2 4 7
contains distinct numbers. There is no subarray with more than numbers that meets the criteria.