#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    vector<int> make(10000);
    vector<int> place(10000);
    int res = INT_MAX;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      make[x]++;
      place[i] = x;
    }
    sort(make.begin(), make.end());
    for (int i = 0; i < n; i++) {
      if (make[i] > 1) {
        res = min(res, i - place[i] + 1);
      }
    }
    if (res == INT_MAX) {
      cout << "-1"
           << "\n";
    } else {
      cout << "res"
           << "\n";
    }
    make.clear();
    place.clear();
  }
}
