#include <bits/stdc++.h>
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    int a[n];
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n - i - 1; j++) {
        if (a[j + 1] < a[j]) {
          int t = a[j];
          a[j] = a[j + 1];
          a[j + 1] = t;
        }
      }
    }
    int ans = INT_MAX;
    for (int i = 0; i < n - 1; i++) {
      if (a[i + 1] - a[i] < ans) {
        ans = a[i + 1] - a[i];
        if (ans == 0) break;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
