#include <bits/stdc++.h>
using namespace std;
const int MAX = 50;
void Get_Array(int n, int a[]) {
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
}
void Print_Array(int n, int a[]) {
  for (int i = 0; i < n; i++) {
    cout << i << "---->" << a[i] << endl;
  }
}
void MG(int k, int m, int v[], int u[], int s[]) {
  int i = 0, j = 0, h = 0;
  while (h < k + m) {
    while (i < k && j < m) {
      if (v[i] < u[j]) {
        s[h] = v[i];
        i++;
      } else {
        s[h] = u[j];
        j++;
      }
      h++;
    }
    if (i = k) {
      int t = j;
      while (t < m) {
        s[h] = u[t];
        h++;
        t++;
      }
    } else if (j = m) {
      int t = i;
      while (t < k) {
        s[h] = v[t];
        h++;
        t++;
      }
    }
  }
}
void MS(int n, int s[]) {
  int v[MAX];
  int u[MAX];
  int m = n / 2;
  int k = n - m;
  for (int i = 0; i < k; i++) {
    s[i] = v[k];
  }
  for (int j = k; j < n; j++) {
    s[j] = u[j];
  }
  MS(k, v);
  MS(m, u);
  MG(k, m, v, u, s);
}
void bubblesort(int n, int s[]) {
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (s[i] > s[j]) {
        swap(s[i], s[j]);
      }
    }
  }
}
int main() {
  int t;
  cin >> t;
  for (int test = 0; test < t; test++) {
    int s[MAX];
    int n;
    cin >> n;
    Get_Array(n, s);
    if (n > 2) {
      bubblesort(n, s);
      int mini = abs(s[1] - s[0]);
      for (int i = 2; i < n; i++) {
        if (abs(s[i] - s[i - 1]) < mini) {
          mini = abs(s[i] - s[i - 1]);
        }
      }
      cout << mini << endl;
    } else if (n == 2) {
      if (s[1] > s[0]) {
        cout << s[1] - s[0] << endl;
      } else {
        cout << s[0] - s[1] << endl;
      }
    }
  }
  return 0;
}
