#include <bits/stdc++.h>
using namespace std;
const int MX = 200003;
int T, a[MX], l[MX], n, res, last;
int main() {
  cin >> T;
  while (T--) {
    memset(l, -1, sizeof(l));
    cin >> n;
    res = n + 10;
    last = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      cout << n << " " << i << " " << l[a[i]] << endl;
      if (l[a[i]] == -1) {
        l[a[i]] = i;
        continue;
      }
      res > i - l[a[i]] ? res = i - l[a[i]] : 1;
      l[a[i]] = i;
    }
    cout << (res == n + 10 ? -1 : res + 1) << endl;
  }
  return 0;
}
