#include <bits/stdc++.h>
using namespace std;
int main() {
  int test;
  cin >> test;
  while (test--) {
    int n;
    cin >> n;
    multiset<int> s;
    s.clear();
    int m = 20000, mx, x;
    for (int i = 0; i < n; i++) {
      cin >> x;
      s.insert(x);
    }
    x = *s.begin();
    while (!s.empty()) {
      s.erase(s.begin());
      if (!s.empty())
        mx = *s.begin();
      else
        break;
      m = min(abs(mx - x), m);
      x = mx;
    }
    cout << m << '\n';
  }
  return 0;
}
