#include <bits/stdc++.h>
using namespace std;
const int INF = 1e5 + 5;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int min = a[1] - a[0];
    for (int i = 2; i < n; i++) {
      int s = a[i] - a[i - 1];
      if (s < min) min = s;
    }
    cout << min << "\n";
    t--;
  }
  return 0;
}
