#include <bits/stdc++.h>
using namespace std;
int t, n;
vector<long long> s;
long long min_;
int main() {
  cin >> t;
  for (int z = 0; z < t; ++z) {
    cin >> n;
    for (int i = 0; i < n; ++i) {
      long long temp;
      cin >> temp;
      s.push_back(temp);
    }
    sort(s.begin(), s.end());
    min_ = s[1] - s[0];
    for (int i = 1; i < n; ++i) {
      long long temp = s[i] - s[i - 1];
      if (temp < min_) min_ = temp;
    }
    cout << min_ << endl;
    s.clear();
  }
  return 0;
}
