K. Ahmad and Distinct Syndrome
time limit per test
2.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Ahmad was a judge of an on-site contest where all contestants were next to each other on a line. At some point in the contest, he noticed that every contestant at that moment solved exactly one problem, meaning each contestant had balloons of only one color; what a coincidence!

There were $$$n$$$ contestants, each with a balloon of color $$$a_i$$$. Ahmad began to wonder: what is the smallest number of consecutive contestants needed to cover all the balloon colors present among the contestants?

More formally, let $$$S(b)$$$ equal the set of distinct colors in array $$$b$$$. What is the length of the smallest subarray $$$a_l, a_{l + 1}, \ldots, a_r$$$ where $$$(1 \leq l \leq r \leq n)$$$ and $$$S(a[l \ldots r]) = S(a)$$$?

Input

The first line of the input contains an integer $$$t$$$ $$$(1 \leq t \leq 10^3$$$) – the number of test cases.

The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 2 \cdot 10^5)$$$ – the number of contestants.

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ $$$(1 \leq a_i \leq n)$$$ – the balloon color of each contestant.

It's guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^6$$$.

Output

For each test case, print the length of the smallest subarray that contains all the distinct colors apparent in $$$a$$$.

Example
Input
3
4
1 2 3 4
5
2 2 2 1 3
6
4 1 2 3 3 4
Output
4
3
4