#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int k = 0; k < n; k++) {
    int s, m = 1000;
    cin >> s;
    int a[s];
    for (int i = 0; i < s; i++) {
      cin >> a[i];
    }
    sort(a, a + s);
    for (int i = 0; i < s - 1; i++) {
      m = min(m, (a[i + 1] - a[i]));
    }
    cout << m << endl;
  }
}
