#include <bits/stdc++.h>
using namespace std;
long long modulo(long long base, long long exp, long long m);
long long powerr(long long base, long long exp, long long m);
long long inverse(long long a, long long m);
const long long nax = 1e5 + 10;
vector<long long> tree(4 * nax);
void update(long long node, long long start, long long end, long long ind,
            long long val) {
  if (start == end) {
    tree[node] = val;
    return;
  }
  long long mid = (start + end) / 2;
  if (start <= ind && ind <= mid)
    update(2 * node + 1, start, mid, ind, val);
  else
    update(2 * node + 2, mid + 1, end, ind, val);
  tree[node] = tree[2 * node + 1] + tree[2 * node + 2];
}
long long query(long long node, long long start, long long end, long long l,
                long long r) {
  if (l > end || r < start) return 0;
  if (l <= start && r >= end) return tree[node];
  long long mid = (start + end) / 2;
  long long p1 = query(2 * node + 1, start, mid, l, r);
  long long p2 = query(2 * node + 2, mid + 1, end, l, r);
  return p1 + p2;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> v(n);
    for (long long i = 0; i < n; i++) cin >> v[i];
    if (n == 1)
      cout << -1 << endl;
    else {
      vector<long long> mind(n + 1, -1);
      long long ans = INT_MAX;
      for (long long i = 0; i < n; i++) {
        if (mind[v[i]] != -1) ans = min(ans, i - mind[v[i]] + 1);
        mind[v[i]] = i;
      }
      if (ans == INT_MAX) ans = -1;
      cout << ans << endl;
    }
  }
  return 0;
}
long long modulo(long long base, long long exp, long long m) {
  long long answer = 1;
  while (exp > 0) {
    if (exp % 2 == 1) answer = (answer * base) % m;
    exp = exp / 2;
    base = (base * base) % m;
  }
  return answer;
}
long long powerr(long long base, long long exp, long long m) {
  base = base % m;
  if (exp == 0)
    return 1;
  else {
    if (exp % 2 == 0) {
      long long x = powerr(base, exp / 2, m);
      return (x * x) % m;
    } else {
      long long x = powerr(base, (exp - 1) / 2, m);
      return ((base % m) * ((x * x) % m)) % m;
    }
  }
}
void EE(long long a, long long b, long long &co1, long long &co2) {
  if (a % b == 0) {
    co1 = 0;
    co2 = 1;
    return;
  }
  EE(b, a % b, co1, co2);
  long long temp = co1;
  co1 = co2;
  co2 = temp - co2 * (a / b);
}
long long inverse(long long a, long long m) {
  long long x, y;
  EE(a, m, x, y);
  if (x < 0) x += m;
  return x;
}

### Prompt

Construct a cpp code solution to the problem outlined:

Let's call an array t dominated by value v in the next situation.

At first, array t should have at least 2 elements. Now, let's calculate number of occurrences of each number num in t and define it as occ(num). Then t is dominated (by v) if (and only if) occ(v) > occ(v') for any other number v'. For example, arrays [1, 2, 3, 4, 5, 2], [11, 11] and [3, 2, 3, 2, 3] are dominated (by 2, 11 and 3 respectevitely) but arrays [3], [1, 2] and [3, 3, 2, 2, 1] are not.

Small remark: since any array can be dominated only by one number, we can not specify this number and just say that array is either dominated or not.

You are given array a_1, a_2, ..., a_n. Calculate its shortest dominated subarray or say that there are no such subarrays.

The subarray of a is a contiguous part of the array a, i. e. the array a_i, a_{i + 1}, ..., a_j for some 1 ≤ i ≤ j ≤ n.

Input

The first line contains single integer T (1 ≤ T ≤ 1000) — the number of test cases. Each test case consists of two lines.

The first line contains single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the array a.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n) — the corresponding values of the array a.

It's guaranteed that the total length of all arrays in one test doesn't exceed 2 ⋅ 10^5.

Output

Print T integers — one per test case. For each test case print the only integer — the length of the shortest dominated subarray, or -1 if there are no such subarrays.

Example

Input


4
1
1
6
1 2 3 4 5 1
9
4 1 2 4 5 4 3 2 1
4
3 3 3 3


Output


-1
6
3
2

Note

In the first test case, there are no subarrays of length at least 2, so the answer is -1.

In the second test case, the whole array is dominated (by 1) and it's the only dominated subarray.

In the third test case, the subarray a_4, a_5, a_6 is the shortest dominated subarray.

In the fourth test case, all subarrays of length more than one are dominated.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long modulo(long long base, long long exp, long long m);
long long powerr(long long base, long long exp, long long m);
long long inverse(long long a, long long m);
const long long nax = 1e5 + 10;
vector<long long> tree(4 * nax);
void update(long long node, long long start, long long end, long long ind,
            long long val) {
  if (start == end) {
    tree[node] = val;
    return;
  }
  long long mid = (start + end) / 2;
  if (start <= ind && ind <= mid)
    update(2 * node + 1, start, mid, ind, val);
  else
    update(2 * node + 2, mid + 1, end, ind, val);
  tree[node] = tree[2 * node + 1] + tree[2 * node + 2];
}
long long query(long long node, long long start, long long end, long long l,
                long long r) {
  if (l > end || r < start) return 0;
  if (l <= start && r >= end) return tree[node];
  long long mid = (start + end) / 2;
  long long p1 = query(2 * node + 1, start, mid, l, r);
  long long p2 = query(2 * node + 2, mid + 1, end, l, r);
  return p1 + p2;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> v(n);
    for (long long i = 0; i < n; i++) cin >> v[i];
    if (n == 1)
      cout << -1 << endl;
    else {
      vector<long long> mind(n + 1, -1);
      long long ans = INT_MAX;
      for (long long i = 0; i < n; i++) {
        if (mind[v[i]] != -1) ans = min(ans, i - mind[v[i]] + 1);
        mind[v[i]] = i;
      }
      if (ans == INT_MAX) ans = -1;
      cout << ans << endl;
    }
  }
  return 0;
}
long long modulo(long long base, long long exp, long long m) {
  long long answer = 1;
  while (exp > 0) {
    if (exp % 2 == 1) answer = (answer * base) % m;
    exp = exp / 2;
    base = (base * base) % m;
  }
  return answer;
}
long long powerr(long long base, long long exp, long long m) {
  base = base % m;
  if (exp == 0)
    return 1;
  else {
    if (exp % 2 == 0) {
      long long x = powerr(base, exp / 2, m);
      return (x * x) % m;
    } else {
      long long x = powerr(base, (exp - 1) / 2, m);
      return ((base % m) * ((x * x) % m)) % m;
    }
  }
}
void EE(long long a, long long b, long long &co1, long long &co2) {
  if (a % b == 0) {
    co1 = 0;
    co2 = 1;
    return;
  }
  EE(b, a % b, co1, co2);
  long long temp = co1;
  co1 = co2;
  co2 = temp - co2 * (a / b);
}
long long inverse(long long a, long long m) {
  long long x, y;
  EE(a, m, x, y);
  if (x < 0) x += m;
  return x;
}

```