#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int powerMod(int x, unsigned int y, int MOD) {
  int res = 1;
  x = x % MOD;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % MOD;
    y = y >> 1;
    x = (x * x) % MOD;
  }
  return res;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int j = 0; j < n; j++) {
      cin >> v[j];
    }
    sort(v.begin(), v.end());
    int min = abs(v[1] - v[0]);
    for (int j = 0; j < n - 1; j++) {
      int temp = abs(v[j] - v[j + 1]);
      if (temp < min) {
        min = temp;
      }
    }
    cout << min << "\n";
  }
  return 0;
}
