#include <bits/stdc++.h>
using namespace std;
long long exp(long long x, long long y, long long p) {
  long long res = 1;
  while (y) {
    if (y % 2) res = (res * x % p) % p;
    x = (x * x) % p;
    y /= 2;
  }
  return res;
}
long long exp(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y % 2) res = (res * x);
    x = (x * x);
    y /= 2;
  }
  return res;
}
long long sv[1000000] = {0};
long long factorialNumInverse[((long long)2e6 + 10) + 1];
long long naturalNumInverse[((long long)2e6 + 10) + 1];
long long fact[((long long)2e6 + 10) + 1];
void InverseofNumber() {
  naturalNumInverse[0] = naturalNumInverse[1] = 1;
  for (long long i = 2; i <= ((long long)2e6 + 10); i++)
    naturalNumInverse[i] = naturalNumInverse[((long long)1e9 + 7) % i] *
                           (((long long)1e9 + 7) - ((long long)1e9 + 7) / i) %
                           ((long long)1e9 + 7);
}
void InverseofFactorial() {
  factorialNumInverse[0] = factorialNumInverse[1] = 1;
  for (long long i = 2; i <= ((long long)2e6 + 10); i++)
    factorialNumInverse[i] =
        (naturalNumInverse[i] * factorialNumInverse[i - 1]) %
        ((long long)1e9 + 7);
}
void factorial() {
  fact[0] = 1;
  for (long long i = 1; i <= ((long long)2e6 + 10); i++) {
    fact[i] = (fact[i - 1] * i) % ((long long)1e9 + 7);
  }
}
long long Binomial(long long n, long long R) {
  long long ans = ((fact[n] * factorialNumInverse[R]) % ((long long)1e9 + 7) *
                   (factorialNumInverse[n - R]) % ((long long)1e9 + 7)) %
                  ((long long)1e9 + 7);
  return ans;
}
long long phi(long long n) {
  long long ans = n;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      ans -= ans / i;
    }
  }
  if (n > 1) ans -= ans / n;
  return ans;
}
void fileIO() {}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long issquare(long long x) {
  long long k = sqrt(x);
  if (k * k == x) return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    long long first[10001] = {0};
    for (long long i = 0; i < n; i++) {
      first[a[i]]++;
    }
    sort(a, a + n);
    bool ok;
    for (long long i = 0; i < 10001; i++) {
      if (first[i] == 1 || first[i] == 0) {
        ok = 1;
      } else {
        ok = 0;
        break;
      }
    }
    if (ok == 1) {
      long long mini = 1000000000;
      for (long long i = 0; i < n - 1; i++) {
        mini = min(mini, a[i + 1] - a[i]);
      }
      cout << mini << "\n";
    } else {
      cout << 0 << "\n";
    }
  }
  return 0;
}
