#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1};
int dy[] = {1, 0};
const long double Pi = acos(-1), e = 2.718;
const int N = 1e6 + 10, mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &x : a) cin >> x;
    sort(a.begin(), a.end());
    int mn = 1e9;
    for (int i = 0; i < n - 1; i++) {
      mn = min(mn, a[i + 1] - a[i]);
    }
    cout << mn << '\n';
  }
  return 0;
}
