#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    sort(arr, arr + n);
    int minn = INT_MAX;
    for (int i = 0; i < n; i++) {
      if (i == 0) {
        minn = min(minn, abs(arr[i] - arr[i + 1]));
        continue;
      }
      if (i == (n - 1)) {
        minn = min(minn, abs(arr[i] - arr[i - 1]));
        continue;
      }
      minn = min(minn, min(abs(arr[i] - arr[i - 1]), abs(arr[i] - arr[i + 1])));
    }
    cout << minn << endl;
  }
}
