#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  for (int i = 1; i <= T; i++) {
    int n;
    cin >> n;
    vector<int> v;
    for (int j = 1; j <= n; j++) {
      int x;
      cin >> x;
      v.push_back(x);
    }
    sort(v.begin(), v.end());
    int ans = v[1] - v[0];
    for (int j = 2; j < n; j++) {
      ans = min(ans, v[j] - v[j - 1]);
    }
    cout << ans << "\n";
  }
  return 0;
}
