#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    vector<int> v;
    int n, k, a, c, flag = 0, x, tlag = 0, dis, q, firstone, y, len, z, vagfol,
                    i, sum = 0, ans, total, coun = 0;
    cin >> n;
    string str;
    for (int i = 0; i < n; i++) {
      cin >> a;
      v.push_back(a);
    }
    sort(v.begin(), v.end());
    int minn = INT_MAX;
    for (int i = 0; i < n - 1; i++) {
      if (v[i + 1] - v[i] < minn) {
        minn = v[i + 1] - v[i];
      }
    }
    cout << minn << endl;
  }
  return 0;
}
