#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int MAX = 1e6;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, ans = INT_MAX;
    cin >> n;
    int arr[n + 5];
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    for (int i = 1; i < n; i++) {
      if (arr[i] - arr[i - 1] < ans) ans = arr[i] - arr[i - 1];
    }
    cout << ans << endl;
  }
  return 0;
}
