#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, i, min, b;
  scanf("%d", &t);
  while (t) {
    scanf("%d", &n);
    int a[n];
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n);
    min = 1001;
    for (i = 0; i < n - 1; i++) {
      b = a[i + 1] - a[i];
      if (b < min) min = b;
    }
    printf("%d\n", min);
    t--;
  }
}
