문제
The cows are in a particularly mischievous mood today! All Farmer John wants to do is take a photograph of the cows standing in a line, but they keep moving right before he has a chance to snap the picture.
Specifically, each of FJ's cows has an integer height from to . FJ wants to take a picture of the cows standing in line in a very specific ordering. If the cows have heights when lined up from left to right, he wants the cow heights to have the following three properties:
He wants the cow heights to increase and then decrease. Formally, there must exist an integer such that .He does not want any cow standing next to another cow with exactly the same height. Formally, for all .He wants the picture to be symmetric. Formally, if , then .
FJ wants the picture to contain as many cows as possible. Specifically, FJ can remove some cows and rearrange the remaining ones. Compute the maximum number of cows FJ can have in the picture satisfying his constraints.
입력
You have to answer multiple test cases.
The first line of input contains a single integer () denoting the number of test cases. test cases follow.
The first line of every test case contains a single integer . The second line of every test case contains integers, the heights of the cows available. The cow heights will be between and .
It is guaranteed the sum of over all test cases will not exceed .
출력
Output lines, the 'th line containing the answer to the 'th test case. Each line should be an integer denoting the maximum number of cows FJ can include in the picture.
예제 입력 1
2
4
1 1 2 3
4
3 3 2 1
예제 출력 1
3
1
점수
Inputs 2-3: Inputs 4-5: , all cows will have height at most 10.Inputs 6-11: No additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인