#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  int size;
  int min;
  vector<int> num;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> size;
    for (int j = 0; j < size; j++) {
      cin >> x;
      num.push_back(x);
    }
    sort(num.begin(), num.end());
    min = abs(num[1] - num[0]);
    for (int j = 0; j < size; j++) {
      if (min > abs(num[j] - num[j - 1])) min = abs(num[j] - num[j - 1]);
    }
    cout << min << endl;
    num.clear();
  }
  return 0;
}
