#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(!cin.tie(0));
  long long int t;
  cin >> t;
  for (long long int p = 1; p <= t; p++) {
    long long int n;
    cin >> n;
    vector<long long int> a(n);
    vector<long long int> diff(n - 1);
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    long long int min = 100000;
    long long int imin = 0;
    for (long long int i = 0; i < n - 1; i++) {
      diff[i] = a[i + 1] - a[i];
      if (diff[i] < min) {
        min = diff[i];
        imin = i;
      }
    }
    cout << min << endl;
  }
}
