## Problem

Let’s call an array B_1, B_2, \ldots, B_M good, if B_i \neq B_{i+1} for any i with 1 \le i \le M-1.

You are given a good array of N positive integers A_1, A_2, A_3, \ldots, A_N.

You can perform the following operations on this array:

• Choose any index i (1 \leq i \leq N) and a number X (1 \leq X \leq 10^9). Then, set A_i to X. After this operation, the array has to remain good.

You want to perform several operations so that the resulting array will contain exactly two distinct values. Determine the smallest number of operations needed to achieve this goal.

### Input Format

• The first line of input contains the integer T, the number of test cases. The description of test cases follows.
• The first line of each test case contains a single integer N  the length of the array.
• The second line of each test case contains N integers A_1, A_2, \dots, A_N  elements of the array.

### Output Format

For each test case, output a single integer  the smallest number of operations needed to achieve an array in which there are exactly two distinct values.

### Constraints

• 1 \leq T \leq 10^5
• 2 \leq N \leq 2 \cdot 10^5
• 1 \leq A_i \leq N
• It’s guaranteed that A_i \neq A_{i+1} for 1 \le i \le N-1 (that is, the array is good).
• The sum of n over all test cases does not exceed 2 \cdot 10^5.

• Subtask 1 (20 points): The sum of N over all test cases does not exceed 100
• Subtask 2 (10 points): The sum of N over all test cases does not exceed 500
• Subtask 3 (25 points): The sum of N over all test cases does not exceed 4000

### Sample 1:

Input

Output

2
5
4 5 2 4 5
2
1 2
3
0


### Explanation:

In the first test case, one of the optimal sequences of operations is:

(4, 5, 2, 4, 5) \to (2, 5, 2, 4, 5) \to (2, 5, 2, 4, 2) \to (2, 5, 2, 5, 2).

In the second test case, the array already contains only two distinct values, so the answer is 0.