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