#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int a = 0; a < t; a++) {
    int n;
    cin >> n;
    int arr[n];
    int diff = INT_MAX;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    sort(arr, arr + n);
    for (int x = 1; x < n; x++) {
      if (arr[x] - arr[x - 1] < diff) diff = arr[x] - arr[x - 1];
    }
    cout << diff << "\n";
  }
  return 0;
}
