#include <bits/stdc++.h>
using namespace std;
bool func(vector<long long int> s1, vector<long long int> s2) {
  return s1[1] < s2[1];
}
string sub(string s1, long long int i, long long int l) {
  string s2 = "";
  for (long long int j = i; j <= l; j++) {
    s2 = s2 + s1[j];
  }
  return s2;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int max3(long long int a, long long int b, long long int c) {
  return max(max(a, b), c);
}
long long int nCr(long long int n, long long int r) {
  long long int x = n - r, y = 0, z = 1;
  while (y < r) {
    z = (z * (x + 1)) / (y + 1);
    x++;
    y++;
  }
  return z;
}
long long int gcd(long long int A, long long int B) {
  if (B != 0) {
    return gcd(B, A % B);
  } else {
    return A;
  }
}
void prime_sieve(long long int *p, long long int n) {
  for (long long int i = 3; i <= n; i += 2) {
    p[i] = 1;
  }
  for (long long int i = 3; i <= n; i += 2) {
    if (p[i] == 1) {
      for (long long int j = i * i; j <= n; j = i + j) {
        p[j] = 0;
      }
    }
  }
  p[2] = 1;
  p[0] = p[1] = 0;
}
long long powers(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = ans * a;
    }
    a = a * a;
    b >>= 1;
  }
  return ans;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, min = INT_MAX;
    cin >> n;
    long long int arr[n];
    for (long long int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    sort(arr, arr + n);
    for (long long int i = 0; i < n - 1; i++) {
      if (arr[i + 1] - arr[i] < min) {
        min = arr[i + 1] - arr[i];
      }
    }
    cout << min << endl;
  }
}
