#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long arr[n];
    for (long long i = 0; i < n; ++i) {
      cin >> arr[i];
    }
    sort(arr, arr + n);
    long long ans = 1000000000;
    for (long long i = 0; i < n - 1; ++i) {
      ans = min(ans, arr[i + 1] - arr[i]);
    }
    cout << ans << endl;
  }
  return 0;
}
