#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, dif = 1001;
    cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    sort(s.begin(), s.end());
    for (int i = 0; i < n - 1; i++) dif = min(dif, s[i + 1] - s[i]);
    cout << dif << endl;
  }
  return 0;
}
