#include <bits/stdc++.h>
const double pi = 3.14159265358979323846;
using namespace std;
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    int* arr = new int[n];
    set<int> s;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      s.insert(arr[i]);
    }
    sort(arr, arr + n);
    int best = INT32_MAX;
    for (int i = 1; i < n; i++) {
      best = min(best, arr[i] - arr[i - 1]);
    }
    cout << best << endl;
    delete[] arr;
  }
  return 0;
}
