Problems
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
He wants the cow heights to increase and then decrease. Formally, there must exist an integer
i such thath_1 \le \dots \le h_i \ge \dots \ge h_K .
He does not want any cow standing next to another cow with exactly the same height. Formally,
h_i \neq h_{i+1} for all1 \le i < K .
He wants the picture to be symmetric. Formally, if
i + j = K+1 , thenh_i = h_j .
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.
Input
You have to answer multiple test cases.
The first line of input contains a single integer
The first line of every test case contains a single integer
It is guaranteed the sum of
Output
Output
Example
2
4
1 1 2 3
4
3 3 2 1
3
1
For the first test case, FJ can take the cows with heights