#include <bits/stdc++.h>
using namespace std;
int main() {
  int no;
  cin >> no;
  while (no--) {
    int size;
    cin >> size;
    int arr[size];
    int i = 0;
    while (i < size) {
      cin >> arr[i++];
    }
    sort(arr, arr + size);
    int least = arr[size - 1] - arr[size - 2], temp;
    for (i = 0; i < size - 2; i++) {
      temp = arr[i + 1] - arr[i];
      if (temp <= least) least = temp;
    }
    cout << least << '\n';
  }
}
