#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    set<int> st;
    int t;
    for (int i = 0; i < n; i++) {
      cin >> t;
      st.insert(t);
    }
    if (st.size() < n)
      cout << 0 << "\n";
    else {
      vector<int> s;
      for (auto x : st) s.push_back(x);
      s.resize(s.size());
      int ans = s[n - 1] - s[0];
      for (int i = 1; i < n; i++) ans = min(ans, s[i] - s[i - 1]);
      cout << ans << "\n";
    }
  }
  return 0;
}
