#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t, n, temp, c = 0, k = INT_MAX;
  vector<int> v;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> temp;
      v.push_back(temp);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n - 1; i++) {
      if (v[i + 1] - v[i] < k)
        k = v[i + 1] - v[i];
      else if (v[i] == v[i + 1]) {
        c = 1;
        break;
      }
    }
    if (c)
      cout << "0"
           << "\n";
    else
      cout << k << "\n";
    v.clear();
    c = 0;
    k = INT_MAX;
  }
  return 0;
}
