#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, i, flag;
  cin >> t;
  while (t--) {
    int x = 10000;
    flag = 0;
    cin >> n;
    int s[n];
    for (i = 0; i < n; i++) {
      cin >> s[i];
    }
    sort(s, s + n);
    for (i = 0; i < n - 1; i++) {
      if (s[i] == s[i + 1]) {
        cout << "0" << endl;
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      int a[n - 1];
      for (i = 0; i < n - 1; i++) {
        a[i] = s[i + 1] - s[i];
      }
      for (i = 0; i < n - 1; i++) {
        if (a[i] < x) {
          x = a[i];
        }
      }
      cout << x << endl;
    }
  }
  return 0;
}
