#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e15;
using Graph = vector<vector<long long>>;
signed main() {
  long long T;
  cin >> T;
  for (long long t = 0; t < T; t++) {
    long long N;
    cin >> N;
    vector<long long> A(N);
    for (long long i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    long long ans = 1000000;
    for (long long i = 1; i < N; i++) {
      ans = min(ans, A[i] - A[i - 1]);
    }
    cout << ans << endl;
  }
}
