#include <bits/stdc++.h>
using namespace std;
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v);
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[ ";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << " ]";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<vector<A>> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) {
      cout << " ";
    }
    cout << v[i];
    if (i < v.size() - 1) {
      cout << "\n";
    }
  }
  return cout << "]";
}
template <typename A, typename B>
istream &operator>>(istream &cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
template <typename T, typename U>
void cmin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
void cmax(T &a, U b) {
  if (a < b) a = b;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int mn = INT_MAX;
  for (int i = 1; i < n; i++) {
    mn = min(mn, abs(a[i] - a[i - 1]));
  }
  cout << mn << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
