There are $n$ athletes in front of you. Athletes are numbered from $1$ to $n$ from left to right. You know the strength of each athlete — the athlete number $i$ has the strength $s_i$.

You want to split all athletes into two teams. Each team must have at least one athlete, and each athlete must be exactly in one team.

You want the strongest athlete from the first team to differ as little as possible from the weakest athlete from the second team. Formally, you want to split the athletes into two teams $A$ and $B$ so that the value $|\max(A) - \min(B)|$ is as small as possible, where $\max(A)$ is the maximum strength of an athlete from team $A$, and $\min(B)$ is the minimum strength of an athlete from team $B$.

For example, if $n=5$ and the strength of the athletes is $s=[3, 1, 2, 6, 4]$, then one of the possible split into teams is:   first team: $A = [1, 2, 4]$,  second team: $B = [3, 6]$. 

In this case, the value $|\max(A) - \min(B)|$ will be equal to $|4-3|=1$. This example illustrates one of the ways of optimal split into two teams.

Print the minimum value $|\max(A) - \min(B)|$.


-----Input-----

The first line contains an integer $t$ ($1 \le t \le 1000$) — the number of test cases in the input. Then $t$ test cases follow.

Each test case consists of two lines. 

The first line contains positive integer $n$ ($2 \le n \le 50$) — number of athletes. 

The second line contains $n$ positive integers $s_1, s_2, \ldots, s_n$ ($1 \le s_i \le 1000$), where $s_i$ — is the strength of the $i$-th athlete. Please note that $s$ values may not be distinct.


-----Output-----

For each test case print one integer — the minimum value of $|\max(A) - \min(B)|$ with the optimal split of all athletes into two teams. Each of the athletes must be a member of exactly one of the two teams.


-----Example-----
Input
5
5
3 1 2 6 4
6
2 1 3 2 4 3
4
7 9 3 1
2
1 1000
3
100 150 200

Output
1
0
2
999
50



-----Note-----

The first test case was explained in the statement. In the second test case, one of the optimal splits is $A=[2, 1]$, $B=[3, 2, 4, 3]$, so the answer is $|2-2|=0$.

Difficulty: EASY
Tags: Sorting

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	li = list(map(int, input().split()))
	li.sort(reverse=True)
	min = li[0] - li[1]
	for i in range(1, n - 1):
		c = li[i] - li[i + 1]
		if c < min:
			min = c
	print(min)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = []
	for i in range(1, n):
		d.append(l[i] - l[i - 1])
	print(min(d))


t = int(input())
for test in range(t):
	n = int(input())
	sub = 1001
	ar = list(map(int, input().strip().split()[:n]))
	for first_loop in range(0, n - 1):
		for second_loop in range(first_loop + 1, n):
			if abs(ar[first_loop] - ar[second_loop]) < sub:
				sub = abs(ar[first_loop] - ar[second_loop])
	print(sub)


for _ in range(int(input().strip())):
	n = int(input().strip())
	L = list(map(int, input().strip().split()))
	L.sort()
	prevMin = 10000000
	for i in range(n - 1):
		if abs(L[i + 1] - L[i]) < prevMin:
			prevMin = abs(L[i + 1] - L[i])
	print(prevMin)


from sys import stdin
for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, stdin.readline().split()))
	t = a[1] - a[0]
	for i in range(1, n):
		if a[i] - a[i - 1] < t:
			t = a[i] - a[i - 1]
	print(t)


testcase = int(input())
for t in range(1, testcase + 1):
	size = int(input())
	elems = list(map(int, input().split(' ')))
	elems.sort()
	diff = 999999999
	for i in range(size - 1):
		if elems[i] == elems[i + 1]:
			diff = 0
			break
		diff = min(abs(elems[i + 1] - elems[i]), diff)
	print(diff)


t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	mind = 1001
	for i in range(n - 1):
		mind = min(ar[i + 1] - ar[i], mind)
	print(mind)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ss = len(set(arr))
	li = []
	if ss < n:
		print(0)
	else:
		arr.sort()
		for i in range(1, n):
			li.append(abs(arr[i - 1] - arr[i]))
		print(min(li))


for case in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	ans = float('inf')
	for i in range(1, n):
		diff = abs(arr[i] - arr[i - 1])
		ans = min(ans, diff)
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	ans = lst[-1] - lst[0]
	for i in range(1, n):
		ans = min(ans, lst[i] - lst[i - 1])
	print(ans)


def coach(n):
	n.sort()
	d = n[1] - n[0]
	e = 0
	for i in range(1, N - 1):
		if n[i + 1] - n[i] < d:
			d = n[i + 1] - n[i]
			e = i
	print(d)
T = int(input())
for k in range(T):
	N = int(input())
	A = [int(x) for x in input().split()]
	coach(A)


for _ in range(int(input())):
	n = int(input())
	S = list(map(int, input().split()))
	S.sort()
	if n == 2:
		print(S[1] - S[0])
		continue
	else:
		ans = 10000
		for i in range(1, n):
			ans = min(S[i] - S[i - 1], ans)
		print(ans)


for i in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	print(min([l[i + 1] - l[i] for i in range(n - 1)]))


t = int(input())
for z in range(t):
	input()
	a = sorted(map(int, input().split()))
	print(min((j - i for (i, j) in zip(a, a[1:]))))


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	l = []
	i = 0
	s.sort()
	while i < n - 1:
		l.append(s[i + 1] - s[i])
		i += 1
	print(min(l))


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = pow(10, 9) + 7

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def solve():
	n = int(inp())
	a = sorted(lis())
	min = a[1] - a[0]
	inidex = 1
	for i in range(2, n):
		if a[i] - a[i - 1] < min:
			inidex = i
			min = a[i] - a[i - 1]
	print(a[inidex] - a[inidex - 1])
testcase(int(inp()))


for _ in range(int(input())):
	N = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = 1000
	for i in range(N - 1):
		ans = min(ans, s[i + 1] - s[i])
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	x = [int(i) for i in input().split()]
	x.sort()
	ans = 99999999
	for i in range(len(x) - 1):
		ans = min(ans, x[i + 1] - x[i])
	print(ans)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	my_list = []
	for i in range(1, len(arr)):
		diff = abs(arr[i - 1] - arr[i])
		my_list.append(diff)
	print(min(my_list))


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	i = 0
	j = 1
	mini = 1000
	for __ in range(n - 1):
		if mini == 0:
			break
		if x[j] - x[i] < mini:
			mini = x[j] - x[i]
		i += 1
		j += 1
	print(mini)


n = int(input())
for i in range(0, n):
	x = int(input())
	m = list(map(int, input().split()))[:x]
	ar = []
	m.sort()
	for j in range(0, x - 1):
		k = m[j + 1] - m[j]
		ar.append(k)
	g = min(ar)
	print(g)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	a = arr[1] - arr[0]
	for i in range(2, n):
		a = min(a, arr[i] - arr[i - 1])
	print(a)


from sys import maxsize
n = int(input())
for i in range(n):
	t = int(input())
	a = list(map(int, input().split()))
	a.sort()
	h = maxsize
	for i in range(1, t):
		if a[i] - a[i - 1] < h:
			h = a[i] - a[i - 1]
	print(h)


def up(arr):
	p = sorted(arr)
	count = []
	d = set(arr)
	if len(p) - len(d) != 0:
		return 0
	else:
		for i in range(len(p) - 1):
			if abs(p[i] - p[i + 1]) == 0:
				print('0')
			else:
				count.append(abs(p[i] - p[i + 1]))
	return min(count)
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	v = up(arr)
	print(v)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		S = list(map(int, input().split()))
		S.sort()
		ans = float('inf')
		for i in range(n - 1):
			ans = min(ans, abs(S[i] - S[i + 1]))
		sys.stdout.write(str(ans) + '\n')
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = l[1] - l[0]
	for i in range(2, n):
		m = min(m, l[i] - l[i - 1])
	print(m)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	sums = [0] * n
	mini = 10000
	for i in range(n):
		sums[i] = abs(a[i - 1] - a[i])
		mini = min(mini, sums[i])
	print(mini)


def best_split_diff(L):
	L.sort()
	diffs = [L[i + 1] - L[i] for i in range(len(L) - 1)]
	return min(diffs)
t = int(input())
for i in range(t):
	n = int(input())
	L = [int(i) for i in input().split()]
	print(best_split_diff(L))


t = int(input())
for q in range(t):
	x = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	m = a[1] - a[0]
	for i in range(2, x):
		if a[i] - a[i - 1] < m:
			m = a[i] - a[i - 1]
	print(m)


for i in range(int(input())):
	n = int(input())
	k = list(map(int, input().split()))
	k.sort()
	p = []
	for i in range(len(k) - 1):
		p.append(abs(k[i] - k[i + 1]))
	a = min(p)
	print(a)


for i in range(int(input())):
	n = int(input())
	athletes = [int(num) for num in input().split()]
	athletes.sort()
	for j in range(n - 1):
		athletes[j] = athletes[j + 1] - athletes[j]
	athletes.pop()
	print(min(athletes))


for r in [*open(0)][2::2]:
	b = sorted(map(int, r.split()))
	print(min((y - x for (x, y) in zip(b, b[1:]))))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	lst = list()
	for i in range(n):
		if i > 0:
			lst.append(l[i] - l[i - 1])
	print(min(lst))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	n = int(input())
	stren = list(map(int, input().split()))
	stren.sort()
	diff = stren[-1]
	for s in range(1, n):
		if stren[s] - stren[s - 1] < diff:
			diff = stren[s] - stren[s - 1]
	print(diff)


Data = []
t = int(input())

def bubble(data):
	changed = True
	while changed:
		changed = False
		for i in range(len(data) - 1):
			if data[i] > data[i + 1]:
				(data[i], data[i + 1]) = (data[i + 1], data[i])
				changed = True
	return data
for i in range(t):
	k = int(input())
	data = input().split()
	for j in range(len(data)):
		data[j] = int(data[j])
	Data.append(data)
for data in Data:
	delta = 0
	data = bubble(data)
	data.reverse()
	for i in range(len(data)):
		for k in range(len(data)):
			if i < k:
				if i == 0 and k == 1:
					delta = data[i] - data[k]
				elif delta > data[i] - data[k]:
					delta = data[i] - data[k]
	print(delta)


def Solution() -> int:
	t = int(input())
	for i in range(t):
		mini = []
		n = int(input())
		s = sorted(map(int, input().split()))
		s.reverse()
		for j in range(n - 1):
			mini.append(s[j] - s[j + 1])
		print(min(mini))
Solution()


def ans(l, n):
	ans = float('inf')
	l.sort()
	for i in range(1, n):
		if l[i] - l[i - 1] < ans:
			ans = l[i] - l[i - 1]
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	print(ans(l, n))


import math
t = int(input())
for z in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	minn = 9999999
	for i in range(0, n - 1):
		if l[i + 1] - l[i] < minn:
			minn = l[i + 1] - l[i]
	print(minn)


t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	min = 1000 ** 1000
	for i in range(n - 1):
		if min > a[i + 1] - a[i]:
			min = a[i + 1] - a[i]
	print(min)
	t -= 1


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split(' ')]
	arr.sort(reverse=True)
	diff = []
	for i in range(len(arr) - 1):
		diff.append(arr[i] - arr[i + 1])
	ans.append(min(diff))
for i in ans:
	print(i)


t = int(input())
input1 = []
for i in range(t):
	tmp = int(input())
	input1.append([int(x) for x in input().split()])
output = []
for list1 in input1:
	list1.sort()
	minDiff = 1001
	for i in range(len(list1) - 1):
		if list1[i + 1] - list1[i] < minDiff:
			minDiff = list1[i + 1] - list1[i]
	output.append(minDiff)
for int1 in output:
	print(int1)


t = int(input())
for i in range(t):
	n = int(input())
	lst1 = list(map(int, input().split()))
	lst1 = sorted(lst1)
	min1 = max(lst1)
	for i in range(len(lst1) - 1):
		min1 = min(min1, abs(lst1[i] - lst1[i + 1]))
	print(min1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	(i, ans) = (0, 1000000000.0)
	while i < n - 1:
		ans = min(a[i + 1] - a[i], ans)
		i += 1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	minimum = a[1] - a[0]
	for i in range(1, len(a) - 1):
		if a[i + 1] - a[i] < minimum:
			minimum = a[i + 1] - a[i]
	print(minimum)


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	if len(l) == 2:
		print(abs(l[0] - l[1]))
	else:
		s = 10000000000000000000000
		for i in range(1, len(l)):
			if l[i] - l[i - 1] < s:
				s = l[i] - l[i - 1]
		print(s)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	x = s[1] - s[0]
	for i in range(2, n):
		x = min(x, s[i] - s[i - 1])
	print(x)


def so(lis):
	lis.sort()
	a = float('inf')
	for i in range(len(lis) - 1):
		a = min(a, lis[i + 1] - lis[i])
		if a < 1:
			return a
	return a
for i in range(int(input())):
	input()
	print(so(list(map(int, input().split()))))


a1 = int(input())
for i in range(a1):
	cv = int(input())
	a = input().split()
	s = []
	for x in range(len(a)):
		s.append(int(a[x]))
	s.sort()
	a = []
	for x in range(1, len(s)):
		a.append(s[x] - s[x - 1])
	a.sort()
	print(a[0])


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	a = []
	for i in range(n - 1):
		c = abs(ar[i] - ar[i + 1])
		a.append(c)
	print(min(a))


for _ in range(int(input())):
	n = int(input())
	lst = [int(i) for i in input().split()]
	lst.sort()
	min1 = lst[1] - lst[0]
	for i in range(2, n):
		c = lst[i] - lst[i - 1]
		if c < min1:
			min1 = c
	print(min1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	ans = 10 ** 6
	for i in range(n):
		for j in range(n):
			if i == j:
				continue
			elif s[i] > s[j]:
				ans = min(ans, s[i] - s[j])
			else:
				ans = min(ans, s[j] - s[i])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	l1 = []
	for i in range(0, len(l) - 1):
		for j in range(i + 1, len(l)):
			l1.append(l[j] - l[i])
	print(min(l1))


T = int(input())
for t in range(0, T):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	res = abs(a[n - 1] - a[n - 2])
	for i in range(n - 1, 0, -1):
		c = abs(a[i] - a[i - 1])
		res = min(res, c)
	print(res)


n = int(input())
c = []
for i in range(n):
	m = int(input())
	a = list(map(int, input().split(' ')))
	a.sort()
	for j in range(len(a) - 1):
		b = abs(a[j] - a[j + 1])
		c.append(b)
	print(min(c))
	c.clear()


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = l[-1]
	for i in range(1, n):
		ans = min(l[i] - l[i - 1], ans)
	print(ans)


from sys import stdin
input = stdin.readline
R = lambda : map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(R())
	v = []
	for i in range(n - 1):
		for j in range(i + 1, n):
			v += (abs(a[i] - a[j]),)
	print(min(v))


def solve():
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mini = float('inf')
	for i in range(1, n):
		mini = min(abs(l[i - 1] - l[i]), mini)
	print(mini)
for _ in range(int(input())):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	arr.sort()
	mini = arr[n - 1] - arr[0]
	for j in range(1, n):
		s = arr[j] - arr[j - 1]
		if s < mini:
			mini = s
		else:
			continue
	print(mini)


for i in range(int(input())):
	n = int(input())
	lst = list()
	x = list(map(int, input().split()))
	x.sort()
	if len(set(x)) != len(x):
		print(0)
	else:
		for i in range(n - 1):
			lst.append(x[i + 1] - x[i])
		print(min(lst))


def solve():
	n = int(input())
	lis = [int(i) for i in input().split()]
	lis.sort()
	m = 100000000
	for i in range(n - 1):
		if abs(lis[i] - lis[i + 1]) < m:
			m = abs(lis[i] - lis[i + 1])
	print(m)
test = int(input())
for i in range(test):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	ch = input()
	L = [int(i) for i in ch.split()]
	Ls = sorted(L)
	minimumL = [Ls[j] - Ls[j - 1] for j in range(1, n)]
	minimum = min(minimumL)
	print(minimum)


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l1.sort()
	k = 10000
	for i in range(1, n):
		if l1[i] - l1[i - 1] < k:
			k = l1[i] - l1[i - 1]
	print(k)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 9999999
	sf = False
	cf = False
	for i in range(n - 1):
		if a[i] == a[i + 1]:
			sf = True
			break
		ans = min(ans, a[i + 1] - a[i])
	if sf == True:
		print('0')
	else:
		print(ans)


import math
t = int(input())
for i in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	l = sorted(l)
	z = 10000
	for j in range(0, n - 1):
		for k in range(j + 1, n):
			p = abs(l[j] - l[k])
			if p < z:
				z = p
	print(z)


t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	d = abs(s[0] - s[1])
	for i in range(1, n - 1):
		if abs(s[i] - s[i + 1]) < d:
			d = abs(s[i] - s[i + 1])
	print(d)


t = int(input())
i = 1
for i in range(t):
	n = int(input())
	s = []
	s = [int(i) for i in input().split()]
	s.sort()
	print(min([s[i] - s[i - 1] for i in range(1, n)]))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	k = a[n - 1] - a[0]
	for i in range(1, n):
		if a[i] - a[i - 1] < k:
			k = a[i] - a[i - 1]
			if k == 0:
				break
	print(k)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a = sorted(a)
	c = a[1] - a[0]
	for i in range(2, n):
		x = a[i] - a[i - 1]
		c = min(x, c)
	print(c)


t = int(input())
while t != 0:
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	l = []
	for i in range(0, len(s) - 1):
		g = abs(s[i] - s[i + 1])
		l.append(g)
	print(min(l))
	t = t - 1


n = int(input())
for _ in range(n):
	m = int(input())
	k = list(map(int, input().split()))
	k.sort()
	ll = []
	for i in range(m - 1):
		ll.append(abs(k[i] - k[i + 1]))
		if k[i] - k[i + 1] == 0:
			break
	print(min(ll))


from math import radians
from heapq import heapify, heappush, heappop
import bisect
from math import pi
from collections import deque
from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li1():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
	return isPrime

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1

def readTree(n):
	adj = [set() for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = map(int, input().split())
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def treeOrderByDepth(n, adj, root=0):
	parent = [-2] + [-1] * (n - 1)
	ordered = []
	q = deque()
	q.append(root)
	depth = [0] * n
	while q:
		c = q.popleft()
		ordered.append(c)
		for a in adj[c]:
			if parent[a] == -1:
				parent[a] = c
				depth[a] = depth[c] + 1
				q.append(a)
	return (ordered, parent, depth)
for _ in range(ii()):
	n = ii()
	l = sorted(li1())
	a = 9999999999999
	for i in range(1, n):
		a = min(a, l[i] - l[i - 1])
	print(a)


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	ans = 10000000000
	for i in range(1, n):
		ans = min(abs(ar[i] - ar[i - 1]), ans)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	m = 1001
	for i in range(n - 1):
		if abs(a[i] - a[i + 1]) < m:
			m = abs(a[i] - a[i + 1])
	print(m)


t = int(input())
a = []
answ = []
for i in range(0, t):
	n = int(input())
	a = map(int, input().split(maxsplit=n))
	a = list(a)
	a.sort()
	min = 123456787654321234567876543212312312321
	for j in range(0, n - 1):
		s = abs(a[j] - a[j + 1])
		if s < min:
			min = s
	answ.insert(i, min)
for i in range(0, t):
	print(answ[i])


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	cost = 100000000000000
	for i in range(0, n - 1):
		delta = abs(arr[i] - arr[i + 1])
		if delta < cost:
			cost = delta
	print(cost)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	m = a[-1]
	for i in range(1, n):
		m = min(m, a[i] - a[i - 1])
	print(m)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	min = 1000000000.0 + 7
	for i in range(n):
		for j in range(i + 1, n):
			if abs(l[i] - l[j]) < min:
				min = abs(l[i] - l[j])
	print(min)


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	c = 1000
	for j in range(n - 1):
		if s[j + 1] - s[j] < c:
			c = s[j + 1] - s[j]
	print(c)


t = int(input(''))
while t != 0:
	t -= 1
	n = int(input(''))
	a = [int(a) for a in input('').split()]
	a = sorted(a)
	li = []
	for i in range(len(a) - 1):
		li.append(a[i + 1] - a[i])
	li = sorted(li)
	print(li[0])


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		n = int(input())
		aa = [int(a) for a in input().split()]
		aa.sort()
		best = 10000
		for i in range(n - 1):
			best = min(best, aa[i + 1] - aa[i])
		print(best)
	q = int(input())
	for _ in range(q):
		solve()
main()


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		arr = [int(k) for k in input().split()]
		mn = 1000000
		for i in range(n):
			for j in range(n):
				if i == j:
					continue
				else:
					mn = min(abs(arr[i] - arr[j]), mn)
		print(mn)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for loop in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = float('inf')
	for i in range(n - 1):
		ans = min(ans, s[i + 1] - s[i])
	print(ans)


n = int(input())
for i in range(n):
	input()
	a = list(map(int, input().split()))
	a.sort()
	champ = 1000000
	for j in range(len(a) - 1):
		if a[j + 1] - a[j] < champ:
			champ = a[j + 1] - a[j]
	print(champ)


for _ in range(int(input())):
	n = int(input())
	m = sorted(map(int, input().split()))
	print(min((y - x for (x, y) in zip(m, m[1:]))))


t = int(input())
for i in range(t):
	n = int(input())
	lst = sorted(list(map(int, input().split())))
	diff = abs(lst[0] - lst[1])
	for i in range(n - 1):
		if abs(lst[i] - lst[i + 1]) < diff:
			diff = abs(lst[i] - lst[i + 1])
	print(diff)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = float('inf')
	for i in range(n - 1):
		d = abs(a[i] - a[i + 1])
		if d < ans:
			ans = d
	print(ans)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	mini = 1000000
	for i in range(n - 1):
		mini = min(s[i + 1] - s[i], mini)
	print(mini)


t = int(input())
from math import ceil
for i in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	nums.sort()
	best = 9999999999
	for j in range(len(nums) - 1):
		if nums[j + 1] - nums[j] < best:
			best = nums[j + 1] - nums[j]
	print(best)


t = int(input())
for j in range(t):
	n = int(input())
	s = sorted(map(int, input().split()))
	ans = min((s[i] - s[i - 1] for i in range(1, n)))
	print(ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mi = 100000
	for i in range(1, n):
		if l[i] - l[i - 1] <= mi:
			mi = l[i] - l[i - 1]
	print(mi)


case_num = int(input())
for i in range(case_num):
	minium = 0
	ath = int(input())
	strength = input().split(' ')
	for j in range(len(strength)):
		strength[j] = int(strength[j])
	strength.sort()
	for j in range(len(strength) - 1):
		if j == 0:
			minium = abs(strength[1] - strength[0])
		elif abs(strength[j + 1] - strength[j]) < minium:
			minium = abs(strength[j + 1] - strength[j])
	print(minium)


t = int(input())
while t > 0:
	t -= 1
	A = []
	n = int(input())
	s = sorted(list(map(int, input().split())))
	for i in range(n - 1):
		A.append(abs(s[i] - s[i + 1]))
	print(min(A))


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 99999999999
	for j in range(n - 1):
		ans = min(ans, abs(arr[j] - arr[j + 1]))
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	x = []
	for i in range(n - 1):
		x.append(abs(l[i] - l[i + 1]))
	print(min(x))


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	S = sorted(map(int, input().split()))
	ANS = 1 << 30
	for i in range(1, n):
		ANS = min(ANS, S[i] - S[i - 1])
	print(ANS)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	inp = list(map(int, input().split(' ')))
	inp.sort()
	dif = 10000
	for i in range(len(inp) - 1):
		val = abs(inp[i] - inp[i + 1])
		if val < dif:
			dif = val
	print(dif)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mini = 99999999
	for i in range(1, n):
		if l[i] - l[i - 1] < mini:
			mini = l[i] - l[i - 1]
	print(mini)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	diff = a[-1]
	for i in range(n - 1):
		if a[i + 1] - a[i] < diff:
			diff = a[i + 1] - a[i]
	print(diff)


for _ in range(int(input())):
	(m, n, a) = (1000, input(), sorted([int(x) for x in input().split()]))
	for (i, j) in zip(a, a[1:]):
		m = min(m, j - i)
	print(m)


import sys

def input():
	return sys.stdin.readline()[:-1]

def main():
	for _ in range(int(input())):
		n = int(input())
		s = sorted(list(map(int, input().split())))
		ans = float('inf')
		for k in range(1, n):
			ans = min(ans, abs(s[k - 1] - s[k]))
		print(ans)
main()


n = int(input())
while n:
	team_size = int(input())
	team = list(map(int, input().split(' ')))
	min_diff = float('inf')
	min_i = min_j = -1
	for i in range(len(team)):
		for j in range(i, len(team)):
			if i != j:
				if abs(team[i] - team[j]) < min_diff:
					min_diff = abs(team[i] - team[j])
					min_i = i
					min_j = j
	print(min_diff)
	n -= 1


def solve(n, arr):
	brr = []
	arr.sort()
	for i in range(n - 1):
		brr.append(arr[i + 1] - arr[i])
	print(min(brr))
test = int(input())
while test != 0:
	n1 = int(input())
	a = list(map(int, input().split(' ')))
	solve(n1, a)
	test -= 1


t = int(input())
min = [0] * t
for k in range(0, t):
	min[k] = 1000
	n = int(input())
	s = list(map(int, input().split()))
	s = sorted(s)
	for i in range(0, n - 1):
		if abs(s[i + 1] - s[i]) <= min[k]:
			min[k] = abs(s[i + 1] - s[i])
for k in range(0, t):
	print(min[k])


import sys
input = sys.stdin.readline

def solve(n, arr):
	diff = abs(arr[0] - arr[1])
	for i in range(n - 1):
		diff = min(diff, abs(arr[i] - arr[i + 1]))
	return diff
t = int(input().strip())
for _ in range(t):
	n = int(input().strip())
	arr = sorted(map(int, input().split()))
	print(solve(n, arr))


import sys
IN = [x.strip() for x in sys.stdin.readlines()]
T = int(IN[0])
for i in range(T):
	n = int(IN[1 + 2 * i])
	athletes = sorted([int(x) for x in IN[2 + 2 * i].split(' ')])
	mindiff = float('inf')
	for i in range(1, n):
		if athletes[i] - athletes[i - 1] < mindiff:
			mindiff = athletes[i] - athletes[i - 1]
	print(f'{mindiff}')


t = int(input())
for o in range(t):
	n = int(input())
	s = [int(i) for i in input().split()]
	s.sort()
	curr_min = 10000000
	for m in range(len(s) - 1):
		diff = abs(s[m + 1] - s[m])
		if diff < curr_min:
			curr_min = diff
	print(curr_min)


t = int(input())
for i in range(t):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	m = s[1] - s[0]
	for j in range(2, len(s)):
		m = min(m, s[j] - s[j - 1])
	print(m)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	d = a[-1]
	for c in range(1, len(a)):
		if abs(a[c] - a[c - 1]) < d:
			d = abs(a[c] - a[c - 1])
	print(d)


q = int(input())
for w in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	i = 0
	ans = 0
	while i < n - 1:
		if a[i + 1] - a[i] < a[ans + 1] - a[ans]:
			ans = i
		i += 1
	print(a[ans + 1] - a[ans])


t = int(input())
c = [0] * t
for i in range(t):
	n = int(input())
	(a, b, *d) = map(int, input().split())
	k = [a, b]
	c[i] = k
	for j in range(len(d)):
		c[i].append(d[j])
		c[i].sort()
l = []

def abs(a, b):
	if a >= b:
		return a - b
	else:
		return b - a
for i in range(len(c)):
	min = abs(c[i][0], c[i][1])
	for j in range(len(c[i]) - 1):
		if min >= abs(c[i][j], c[i][j + 1]):
			min = abs(c[i][j], c[i][j + 1])
	print(min)


import itertools
t = int(input())
while t > 0:
	n = int(input())
	s = [int(x) for x in input().split()]
	if len(s) > 1:
		m = abs(s[0] - s[1])
	else:
		m = 0
	for (n1, n2) in itertools.combinations(s, 2):
		diff = abs(n1 - n2)
		if m > diff:
			m = diff
	print(m)
	t -= 1


import sys
import collections

def set_debug(debug_mode=False):
	if debug_mode:
		fin = open('input.txt', 'r')
		sys.stdin = fin
t = int(input())
for ti in range(1, t + 1):
	n = int(input())
	s = list(map(int, input().split()))
	res = float('inf')
	s.sort()
	for i in range(1, len(s)):
		res = min(res, s[i] - s[i - 1])
		if res == 0:
			break
	print(res)


n = int(input())

def calc(a, l):
	c = max(a)
	for i in range(l):
		for j in range(i + 1, l):
			if abs(a[i] - a[j]) < c:
				c = abs(a[i] - a[j])
	print(c)
for i in range(n):
	l = int(input())
	a = list(map(int, input().split()))
	calc(a, l)


for i in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort(reverse=True)
	x = 2147483648
	for i in range(n - 1):
		if lis[i] - lis[i + 1] < x:
			x = lis[i] - lis[i + 1]
	print(x)


t = int(input())
for i in range(t):
	n = int(input())
	my_list = sorted(list(map(int, input().split())))
	answer = my_list[1] - my_list[0]
	for j in range(n - 1):
		if my_list[j + 1] - my_list[j] < answer:
			answer = my_list[j + 1] - my_list[j]
	print(answer)


def fun(y):
	t = -1
	y = sorted(y)
	for i in range(len(y) - 1):
		if y[i + 1] - y[i] < t or t < 0:
			t = y[i + 1] - y[i]
	return t
a = int(input())
x = []
for i in range(a):
	t = input()
	x.append(list(map(int, input().split())))
for i in range(a):
	print(fun(x[i]))


def solve(n, a):
	ans = 10 ** 5
	for i in range(n - 1):
		ans = min(ans, a[i + 1] - a[i])
	return ans

def bruh():
	t = int(input())
	ans = [0] * t
	for i in range(t):
		n = int(input())
		a = [int(i) for i in input().split()]
		ans[i] = solve(n, sorted(a))
	print('\n'.join(map(str, ans)))
bruh()


import math as mt
import sys, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
n = I()
for _ in range(n):
	t = I()
	l = L()
	l.sort()
	a = 10 ** 10
	for i in range(1, t):
		if abs(l[i] - l[i - 1]) < a:
			a = abs(l[i] - l[i - 1])
	print(a)


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	a = []
	for x in range(n - 1):
		a.append(li[x + 1] - li[x])
	print(min(a))


t = int(input())
for i in range(t):
	n = int(input())
	s = list(sorted(map(int, input().split())))
	ans = s[1] - s[0]
	for i in range(1, n - 1):
		if s[i + 1] - s[i] < ans:
			ans = s[i + 1] - s[i]
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mini = max(a)
	for i in range(len(a) - 1):
		if abs(a[i + 1] - a[i]) < mini:
			mini = abs(a[i + 1] - a[i])
	print(mini)


import sys
import time
st = time.perf_counter()
number = int(input())
for __ in range(number):
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort()
	mn = 1001001001
	for i in range(1, len(ls)):
		mn = min(mn, ls[i] - ls[i - 1])
	print(mn)
ed = time.perf_counter()
print('time:', ed - st, file=sys.stderr)


testin = int(input())
for i in range(testin):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	minCheck = arr[0] - arr[1]
	for j in range(1, len(arr)):
		if arr[j - 1] - arr[j] < minCheck:
			minCheck = arr[j - 1] - arr[j]
	print(minCheck)


a = int(input())
for i in range(a):
	l = 1001
	b = int(input())
	c = list(map(int, input().split()))
	if len(set(c)) != b:
		print(0)
	else:
		c.sort(reverse=True)
		for j in range(b - 1):
			x = c[j] - c[j + 1]
			if x < l:
				l = x
			else:
				continue
		print(l)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def solve(arr, n):
	arr = sorted(arr)
	ans = float('inf')
	for i in range(1, n):
		ans = min(ans, arr[i] - arr[i - 1])
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(arr, n))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	minim = 10000000
	for i in range(n - 1):
		if minim > a[i + 1] - a[i]:
			minim = a[i + 1] - a[i]
	print(minim)


t = int(input())
for i in range(t):
	n = int(input())
	ath = list(map(int, input().split()))
	ath = sorted(ath)
	c = 0
	for j in range(1, len(ath)):
		if ath[j] == ath[j - 1]:
			c = 1
			print(0)
			break
	if c == 0:
		mn = 10000000
		for j in range(0, len(ath) - 1):
			if mn > abs(ath[j + 1] - ath[j]):
				mn = abs(ath[j + 1] - ath[j])
		print(mn)


from sys import stdin, stdout
t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, stdin.readline().split()))
	diff = float('inf')
	for i in range(len(s) - 1):
		for j in range(i + 1, len(s)):
			if abs(s[i] - s[j]) < diff:
				diff = abs(s[i] - s[j])
	print(diff)


t = int(input())
for qwe in range(t):
	n = int(input())
	listt = list(map(int, input().split()))
	listt.sort()
	ans = 9999999999
	ansind = 0
	for i in range(1, n):
		if abs(listt[i] - listt[i - 1]) < ans:
			ans = abs(listt[i] - listt[i - 1])
	print(ans)


cases = int(input())
for case in range(cases):
	_num_atl = int(input())
	_fuerzas = input()
	fuerzas = _fuerzas.split()
	fuerzas = [int(i) for i in fuerzas]
	fuerzas.sort()
	min_fuerza = -1
	for (key, i) in enumerate(fuerzas):
		if key == 0:
			min_fuerza = abs(i - fuerzas[1])
		elif i - fuerzas[key - 1] < min_fuerza:
			min_fuerza = i - fuerzas[key - 1]
	print(min_fuerza)


for _ in range(int(input())):
	a = int(input())
	b = [int(i) for i in input().split()]
	res = max(b) - min(b)
	b.sort()
	for i in range(a - 1):
		if b[i + 1] - b[i] < res:
			res = b[i + 1] - b[i]
	print(res)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	ans = a[1] - a[0]
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = 1000000
	for i in range(n - 1):
		if l[i + 1] - l[i] < d:
			d = l[i + 1] - l[i]
	print(d)


def findMinDiff(arr, n):
	arr = sorted(arr)
	diff = 10 ** 20
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < diff:
			diff = arr[i + 1] - arr[i]
	return diff
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(findMinDiff(a, n))


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	if len(set(s)) != len(s):
		print(0)
	else:
		c = 1001
		for i in range(1, n):
			d = abs(s[i - 1] - s[i])
			c = min(c, d)
		print(c)


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	res = 1001
	for i in range(1, n):
		res = min(res, a[i] - a[i - 1])
	print(res)
	t -= 1


from sys import stdin, stdout
import sys
from math import *
input = stdin.readline
for __ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = inf
	l.sort()
	for i in range(1, n):
		ans = min(ans, l[i] - l[i - 1])
	print(ans)


t = int(input())
result = []
while t != 0:
	n = []
	l = []
	d = []
	n = int(input())
	s = []
	f = input()
	l = f.split()
	for i in range(0, n):
		s.append(int(l[i]))
	for i in range(n):
		for j in range(n):
			if j <= i:
				pass
			else:
				d.append(abs(s[i] - s[j]))
	f1 = []
	f2 = []
	for i in range(n):
		for j in range(n):
			if j <= i:
				pass
			elif abs(s[i] - s[j]) == min(d):
				f1.append(s[i])
				f2.append(s[j])
	A = []
	B = []
	for i in range(0, len(s)):
		if s[i] == max(f2):
			a = s.pop(i)
			A.append(a)
			break
	for i in range(0, len(s)):
		if s[i] == max(f1):
			b = s.pop(i)
			B.append(b)
			break
	for i in s:
		if i >= B[0]:
			B.append(i)
		elif i <= A[0]:
			A.append(i)
	result.append(abs(max(A) - min(B)))
	t -= 1
for i in result:
	print(i)


t = int(input())
answer = []
for a in range(t):
	n = int(input())
	line = [int(i) for i in input().split()]
	line.sort()
	result = line[n - 1] - line[0]
	for i in range(n):
		for j in range(i + 1, n):
			result = min(result, line[j] - line[i])
	answer.append(result)
for b in answer:
	print(str(b))


def calc(n, a):
	a.sort()
	m = 10 ** 12
	for i in range(1, n):
		m = min(abs(a[i] - a[i - 1]), m)
	print(m)
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	calc(n, a)


for _ in range(int(input())):
	input()
	s = sorted(map(int, input().split()))
	min_diff = 1000
	for i in range(1, len(s)):
		diff = abs(s[i - 1] - s[i])
		if diff < min_diff:
			min_diff = diff
	print(min_diff)


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	diff = l[1] - l[0]
	for j in range(n - 1):
		if l[j + 1] - l[j] < diff:
			diff = l[j + 1] - l[j]
	print(diff)


R = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	n = R()[0]
	a = R()
	a.sort()
	for i in range(n - 1, 0, -1):
		a[i] -= a[i - 1]
	print(min(a[1:]))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	mini = 99999999999
	for i in range(len(arr) - 1):
		if arr[i + 1] - arr[i] < mini:
			mini = arr[i + 1] - arr[i]
	print(mini)


def findMinDiff(arr, n):
	diff = 10 ** 20
	for i in range(n - 1):
		for j in range(i + 1, n):
			if abs(arr[i] - arr[j]) < diff:
				diff = abs(arr[i] - arr[j])
	return diff
t = int(input())
for i in range(t):
	k = int(input())
	a = [x for x in map(int, input().split())]
	print(findMinDiff(a, k))


n = int(input())
for i in range(n):
	z = 999999
	t = int(input())
	l = list(map(int, input().split()))
	l.sort()
	for q in range(len(l) - 1):
		if l[q + 1] - l[q] < z:
			z = l[q + 1] - l[q]
	print(z)


testCases = int(input())
for _ in range(testCases):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	small = 1000
	for index in range(n - 1):
		small = min(small, s[index + 1] - s[index])
		if small == 0:
			break
	print(small)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	res = 100000
	for i in range(len(arr) - 1):
		mini = -arr[i] + arr[i + 1]
		if mini < res:
			res = mini
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	list1 = list(map(int, input().split()))
	listless = []
	for i in range(n):
		s1 = 0
		s2 = max(list1)
		res1 = ''
		for j in range(n):
			if list1[j] <= list1[i] and list1[j] >= s1 and (i != j):
				s1 = list1[j]
				res1 = list1[i]
		try:
			listless.append(abs(s1 - res1))
		except:
			for j in range(n):
				if list1[j] >= list1[i] and list1[j] <= s2 and (i != j):
					s2 = list1[j]
					res2 = list1[i]
			listless.append(abs(s2 - res2))
	print(min(listless))


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().strip().split()))[:n]
	a = sorted(arr, reverse=True)
	diff = 11111111
	for i in range(0, len(a) - 1):
		if a[i] - a[i + 1] < diff:
			diff = a[i] - a[i + 1]
	t = t - 1
	print(diff)


import math
t = int(input())
for i in range(t):
	res = math.inf
	n = int(input())
	strength = input().split()
	strength = [int(elem) for elem in strength]
	strength.sort(reverse=True)
	for i in range(len(strength) - 1):
		first = strength[i]
		second = strength[i + 1]
		if first - second < res:
			res = first - second
	print(res)


def to_list(s):
	return list(map(lambda x: int(x), s.split(' ')))

def solve(a):
	sorted_a = sorted(a)
	if len(a) == 2:
		return str(abs(a[0] - a[1]))
	else:
		min_diff = sorted_a[1] - sorted_a[0]
		for i in range(2, len(a)):
			if sorted_a[i] - sorted_a[i - 1] < min_diff:
				min_diff = sorted_a[i] - sorted_a[i - 1]
		return str(min_diff)
t = int(input())
answers = []
for i in range(t):
	n = int(input())
	a = to_list(input())
	answers.append(solve(a))
print('\n'.join(answers))


import sys

def get_optimal_value(athletes: list) -> int:
	athletes.sort()
	min_diff = max(athletes)
	for (i, athlete) in enumerate(athletes[:-1]):
		next_athlete = athletes[i + 1]
		diff = abs(next_athlete - athlete)
		if diff < min_diff:
			min_diff = diff
	return min_diff
for line in sys.stdin:
	if ' ' in line:
		athletes = list(map(int, line.split(' ')))
		print(get_optimal_value(athletes))


def coach(strength, n):
	strength = sorted(strength)
	res = 1000
	for i in range(n - 1):
		x = abs(strength[i] - strength[i + 1])
		if x == 0:
			return x
		if x < res:
			res = x
	return res
for _ in range(int(input())):
	n = int(input())
	main = list(map(int, input().split()))
	print(coach(main, n))


t = int(input())
while t:
	n = int(input())
	l1 = list(map(int, input().split()))
	l1.sort()
	min = 1001
	for i in range(1, n):
		check = abs(l1[i] - l1[i - 1])
		if check < min:
			min = check
	print(min)
	t = t - 1


from __future__ import division, print_function
import os, sys
import math
import collections
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def binary_search(arr, low, high, x):
	if high >= low:
		mid = (high + low) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binary_search(arr, low, mid - 1, x)
		else:
			return binary_search(arr, mid + 1, high, x)
	else:
		return -1

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def padded_bin_with_complement(x):
	if x < 0:
		return bin(2 ** 16 - abs(x))[2:].zfill(16)
	else:
		return bin(x)[2:].zfill(16)

def binaryToDecimal(binary):
	binary1 = binary
	(decimal, i, n) = (0, 0, 0)
	while binary != 0:
		dec = binary % 10
		decimal = decimal + dec * pow(2, i)
		binary = binary // 10
		i += 1
	print(decimal)

def CountFrequency(arr):
	return collections.Counter(arr)

def pos(a):
	b = [0] * len(a)
	c = sorted(a)
	for i in range(len(a)):
		for j in range(len(a)):
			if c[j] == a[i]:
				b[i] = j
				break
	return b

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		b = []
		a.sort()
		for i in range(n - 1):
			b.append(abs(a[i] - a[i + 1]))
		print(min(b))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


a = int(input())
for i in range(a):
	b = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	mi = max(l)
	for d in range(len(l)):
		for g in range(d, len(l)):
			if d != g:
				if l[d] - l[g] < mi:
					mi = l[d] - l[g]
	print(mi)


for t in range(int(input())):
	n = input()
	ath = list(map(int, input().split()))
	m = abs(ath[0] - ath[1])
	for i in range(len(ath)):
		for j in range(i + 1, len(ath)):
			if abs(ath[i] - ath[j]) < m:
				m = abs(ath[i] - ath[j])
	print(m)


testcases = int(input())
for i in range(testcases):
	n = int(input())
	strength = input().split()
	st = list()
	for j in strength:
		st.append(int(j))
	st.sort()
	ans = list()
	for k in range(n - 1):
		ans.append(st[k + 1] - st[k])
	print(min(ans))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = []
	for i in range(1, n):
		a.append(l[i] - l[i - 1])
	print(min(a))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	a = []
	for i in range(n - 1):
		a.append(arr[i + 1] - arr[i])
	b = min(a)
	print(b)


from sys import stdin
import math
n = int(stdin.readline())
for _ in range(n):
	stdin.readline()
	nums = list(map(int, stdin.readline().rstrip().split(' ')))
	nums.sort()
	mi = math.inf
	for i in range(len(nums) - 1):
		mi = min(abs(nums[i] - nums[i + 1]), mi)
	print(mi)


for i in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	if n == 2:
		print(abs(l1[1] - l1[0]))
		continue
	elif n > 2:
		l1.sort()
		l2 = []
		for j in range(n):
			if j == n - 1:
				break
			l2.append(l1[j + 1] - l1[j])
	print(min(l2))


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	mi = 10000
	prev = 10000
	lis.sort()
	for i in lis:
		mi = min(mi, abs(prev - i))
		prev = i
	print(mi)


def spt():
	input()
	sp = sorted([int(i) for i in input().split()])
	s = [abs(sp[i] - sp[i - 1]) for i in range(1, len(sp))]
	print(min(s))
[spt() for i in range(int(input()))]


t = int(input())
for i in range(t):
	n = int(input())
	powers = list(map(int, input().split(' ')))
	powers.sort()
	minimal = 1000
	j = 0
	while j != n - 1:
		diff = (powers[j] - powers[j + 1]) * -1
		if diff < minimal:
			minimal = diff
		j += 1
	print(minimal)


n = int(input())
for i in range(n):
	a = int(input())
	k = list(map(int, input().split()))
	k = sorted(k)
	m = None
	for j in range(len(k) - 1):
		x = abs(int(k[j]) - int(k[j + 1]))
		if m is None or x < m:
			m = x
	print(m)


r = int(input())
for i in range(r):
	n = int(input())
	num = input()
	list = [int(x) for x in num.split()]
	l = sorted(list)
	k = []
	for i in range(1, n):
		g = l[-i] - l[-(i + 1)]
		k.append(g)
	print(min(k))


import math
import sys
from sys import *
from bisect import insort
import heapq
import collections
from collections import deque, defaultdict
from itertools import permutations, combinations, combinations_with_replacement
import random
import os
mod = 10 ** 9 + 7
MAX = sys.maxsize
MIN = -sys.maxsize - 1

def isPrime(n):
	if n > 1:
		for i in range(2, n):
			if n % i == 0:
				return False
		else:
			return True
	else:
		return False

def isPanagram(s):
	alphabet = 'abcdefghijklmnopqrstuvwxyz'
	for char in alphabet:
		if char not in s.lower():
			return False
	return True

def isEqual(list1):
	if len(list1) < 0:
		res = True
	res = all((ele == list1[0] for ele in list1))
	if res:
		return True
	else:
		return False

def remove_duplicate(list1):
	final_list = []
	for i in list1:
		if i not in final_list:
			final_list.append(i)
	return final_list % mod

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	dp = []
	for i in range(len(arr)):
		for j in range(i + 1, len(arr)):
			dp.append(abs(arr[i] - arr[j]))
	return min(dp)
t = int(stdin.readline())
for i in range(t):
	result = solve()
	stdout.write(str(result) + '\n')


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		nums = list(map(int, input().split()))
		nums.sort()
		min_diff = float('inf')
		for i in range(len(nums) - 1):
			min_diff = min(min_diff, abs(nums[i] - nums[i + 1]))
		print(min_diff)
main()


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	li.append(10000000000)
	li.sort()
	z = 1000000000000
	for i in range(n):
		if li[i + 1] - li[i] < z:
			z = li[i + 1] - li[i]
	print(z)


t = int(input())
for _ in range(t):
	p = []
	n = int(input())
	l = list(map(int, input().split(' ')))
	for x in range(n):
		for y in range(n):
			if x != y:
				p.append(abs(l[x] - l[y]))
	print(min(p))


from fractions import Fraction
import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
t = 1
for _ in range(iinput()):
	n = iinput()
	a = rlinput()
	a.sort()
	ans = 99999999999999
	for i in range(n - 1):
		ans = min(ans, a[i + 1] - a[i])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = a[1] - a[0]
	for i in range(1, len(a) - 1):
		b = min(b, a[i + 1] - a[i])
	print(b)


t = int(input())
for t_ in range(t):
	n = int(input())
	ath = list(map(int, input().split()))
	ath.sort()
	min = 2 * ath[-1]
	for i in range(1, n):
		if ath[i] - ath[i - 1] < min:
			min = ath[i] - ath[i - 1]
	print(min)


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	mn = []
	for j in range(n - 1):
		mn.append(s[j + 1] - s[j])
	print(min(mn))


t = int(input())
for i in range(t):
	mn = 1000
	n = int(input())
	s = sorted(list(map(int, input().split())))
	for j in range(n - 1):
		if s[j + 1] - s[j] < mn:
			mn = s[j + 1] - s[j]
	print(mn)


for i in range(int(input())):
	c = int(input())
	f = sorted([int(i) for i in input().split()])
	k = 1000000000000
	for j in range(1, c):
		k = min(k, f[j] - f[j - 1])
	print(k)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mn = 10000
	for i in range(len(a) - 1):
		if mn > a[i + 1] - a[i]:
			mn = a[i + 1] - a[i]
	print(mn)
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


from math import ceil
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 10 ** 6
	for i in range(1, len(arr)):
		ans = min(ans, arr[i] - arr[i - 1])
	print(ans)


t = int(input())
for y in range(t):
	d = {}
	n = int(input())
	s = sorted([int(x) for x in input().split()])
	minDiff = float('inf')
	for i in range(1, n):
		minDiff = min(minDiff, s[i] - s[i - 1])
	print(minDiff)


case = int(input())
for i in range(case):
	n = int(input())
	list1 = [int(v) for v in input().split()]
	list1.sort()
	list2 = []
	for j in range(n - 1):
		list2.append(abs(list1[j + 1] - list1[j]))
	print(min(list2))


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 10 ** 18
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	dif = max(A) - min(A)
	for i in range(n - 1):
		if A[i + 1] - A[i] < dif:
			dif = A[i + 1] - A[i]
		if dif == 0:
			break
	print(dif)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	l = []
	for j in range(len(arr) - 1):
		l.append(arr[j + 1] - arr[j])
	print(min(l))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	best = 99999999
	if len(set(a)) != len(a):
		print(0)
	else:
		for j in range(len(a)):
			for l in range(len(a)):
				if j != l:
					best = min(best, abs(a[j] - a[l]))
		print(best)


for t in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = abs(s[0] - s[1])
	for i in range(0, n - 1):
		ans = min(ans, abs(s[i] - s[i + 1]))
	print(ans)


def main():
	iterations = int(input())
	answer = []
	for i in range(iterations):
		amount_of_players = int(input())
		players = input().split()
		for player in range(len(players)):
			players[player] = int(players[player])
		players = sorted(players)
		minimum = max(players)
		for player in range(len(players) - 1):
			if abs(players[player] - players[player + 1]) < minimum:
				minimum = abs(players[player] - players[player + 1])
		answer.append(minimum)
	for ans in answer:
		print(ans)
main()


from itertools import combinations
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mycombination = list(combinations(arr, 2))
	print(min([abs(i[0] - i[1]) for i in mycombination]))


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 2 ** 31 - 1
	p1 = n - 1
	p2 = n - 2
	while p2 >= 0:
		ans = min(ans, abs(a[p1] - a[p2]))
		p1 -= 1
		p2 -= 1
	print(ans)


for i in range(int(input())):
	n = int(input())
	team = list(map(int, input().split()))
	team = sorted(team)
	mini = None
	res = max(team)
	for i in range(n - 1):
		if mini is None or team[i + 1] - team[i] < mini:
			mini = team[i + 1] - team[i]
	print(mini)


ans = []
for _ in range(int(input())):
	n = int(input())
	u = list(map(int, input().split()))
	u.sort()
	ansi = 100000
	for i in range(1, n):
		ansi = min(ansi, u[i] - u[i - 1])
	ans.append(ansi)
print('\n'.join(map(str, ans)))


n = int(input())
for i in range(n):
	a = int(input())
	m = 999
	b = list(map(int, input().split()))
	b = sorted(b)
	for j in range(len(b) - 1):
		if abs(b[j] - b[j + 1]) < m:
			m = abs(b[j] - b[j + 1])
	print(m)


for _ in range(int(input())):
	n = int(input())
	s = [int(i) for i in input().split()]
	s.sort()
	a = s[1] - s[0]
	for i in range(2, n):
		a = min(a, s[i] - s[i - 1])
	print(a)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	y = 10 ** 9
	for i in range(n - 1):
		x = l[i + 1] - l[i]
		if y > x:
			y = x
	print(y)


from math import *
t = int(input())
m = []
n = []
for i in range(t):
	y = input()
	x = list(map(int, input().split()))
	x.sort()
	m.append(x)
for i in range(t):
	tmp = m[i][1] - m[i][0]
	for j in range(len(m[i]) - 1):
		if m[i][j + 1] - m[i][j] < tmp:
			tmp = m[i][j + 1] - m[i][j]
	print(tmp)


n = int(input())
l = []
for i in range(0, n):
	n1 = int(input())
	s = [int(x) for x in input().split()]
	l.append(s)
for j in range(0, n):
	l2 = []
	l[j].sort()
	for k in range(0, len(l[j]) - 1):
		diff = l[j][k + 1] - l[j][k]
		l2.append(diff)
	print(min(l2))


for _ in range(int(input())):
	n = int(input())
	x = [int(x) for x in input().split()]
	x.sort()
	min = 10 ** 9
	for i in range(1, len(x)):
		z = abs(x[i] - x[i - 1])
		if z < min:
			min = z
	print(min)


a = int(input())
for fewfweefw in range(a):
	integer = int(input())
	lst = input().split()
	lst = [int(p) for p in lst]
	lst = sorted(lst)
	count = 843513865668464568495138465143865134386513
	for val in range(len(lst)):
		if val != 0:
			if abs(lst[val] - lst[val - 1]) < count:
				count = abs(lst[val] - lst[val - 1])
	print(count)


def merge_sort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		left = arr[:mid]
		right = arr[mid:]
		left = merge_sort(left)
		right = merge_sort(right)
		arr = []
		while len(left) > 0 and len(right) > 0:
			if left[0] < right[0]:
				arr.append(left[0])
				left.pop(0)
			else:
				arr.append(right[0])
				right.pop(0)
		for i in left:
			arr.append(i)
		for i in right:
			arr.append(i)
	return arr
t = int(input())
for i in range(t):
	n = int(input())
	v = [int(x) for x in input().split()]
	v = merge_sort(v)
	check_list = (len(v) - 1) * [0]
	for i in range(n - 1):
		check_list[i] = v[i + 1] - v[i]
	min = 10000
	k = -1
	j = -1
	for i in check_list:
		j = j + 1
		if i < min:
			k = j
			min = i
	v1 = v[:k + 1]
	v2 = v[k + 1:]
	print(v2[0] - v1[k])


t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(i) for i in input().split()]
	s = sorted(s)
	mn = max(s)
	for i in range(1, n):
		diff = s[i] - s[i - 1]
		mn = min(mn, diff)
	print(mn)


def main():
	for t in range(int(input())):
		n = int(input())
		a = [int(i) for i in input().split()]
		a.sort()
		minDiff = a[-1]
		for i in range(1, n):
			minDiff = min(minDiff, a[i] - a[i - 1])
		print(minDiff)
main()


t = int(input())
for k in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	g_max = 2 ** 32
	for i in range(n - 1, 0, -1):
		if abs(s[i] - s[i - 1]) <= g_max:
			g_max = s[i] - s[i - 1]
	print(g_max)


for i in range(int(input())):
	n = int(input())
	c = sorted(list(map(int, input().split(' '))))
	d = []
	for i in range(n - 1):
		d.append(c[i + 1] - c[i])
	d.sort()
	print(d[0])


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	z = float('inf')
	for j in range(1, n):
		z = min(z, l[j] - l[j - 1])
	print(z)


t = int(input())
for x in range(t):
	q = int(input())
	l = list(map(int, input().split()))[:q]
	l.sort()
	w = 9999
	for j in range(1, q):
		w = min(w, l[j] - l[j - 1])
	print(w)


z = int(input())
for f in range(z):
	x = int(input())
	y = list(map(int, input().strip().split()))[:x]
	y.sort()
	dif = []
	for i in range(x - 1):
		dif.append(y[i + 1] - y[i])
	dif.sort()
	print(dif[0])


n = int(input())
for t in range(n):
	q = int(input())
	b = input().split()
	c = []
	for i in b:
		c.append(int(i))
	c.sort()
	m = c[1] - c[0]
	for j in range(1, len(c)):
		m = min(m, c[j] - c[j - 1])
	print(m)


def main():
	import sys
	input = sys.stdin.readline
	sys.setrecursionlimit(10 ** 7)
	from collections import Counter, deque
	from itertools import combinations, permutations, accumulate, groupby, product
	from bisect import bisect_left, bisect_right
	from heapq import heapify, heappop, heappush
	import math
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = list(map(int, input().split()))
		s.sort()
		res = 100000
		for i in range(n - 1):
			if s[i + 1] - s[i] < res:
				res = s[i + 1] - s[i]
		print(res)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	aths = [int(x) for x in input().split()]
	aths.sort()
	diff = float('inf')
	for i in range(n - 1):
		if aths[i + 1] - aths[i] < diff:
			diff = aths[i + 1] - aths[i]
	print(diff)


t = int(input())
for x in range(t):
	n = int(input())
	ls = list(map(int, input().split()))
	s = set(ls)
	mn = 1000
	if len(s) < n:
		print(0)
		continue
	else:
		ls = sorted(ls)
		for i in range(n - 1):
			r = ls[i + 1] - ls[i]
			if mn > r:
				mn = r
		print(mn)


num = int(input())
lst = []
for i in range(num):
	n = int(input())
	lst2 = []
	lst1 = sorted(list(map(int, input().split())))
	for j in range(1, n):
		lst2.append(abs(lst1[j] - lst1[j - 1]))
	lst.append(min(lst2))
for var in lst:
	print(var)


def solve(a):
	b = sorted(a)
	return min([b[i + 1] - b[i] for i in range(len(b) - 1)])
t = int(input())
for i_t in range(t):
	input()
	a = list(map(int, input().split(' ')))
	print(solve(a))


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	l = sorted(li())
	ans = float('inf')
	for i in range(1, n):
		ans = min(ans, l[i] - l[i - 1])
	print(ans)


def sol():
	n = int(input())
	sizes = []
	arrays = []
	for _ in range(n):
		sizes.append(int(input()))
		arrays.append([int(x) for x in input().split()])
	for i in range(len(arrays)):
		array = sorted(arrays[i])
		new_array = []
		for c in range(len(array) - 1):
			new_array.append(abs(array[c] - array[c + 1]))
		print(min(new_array))
sol()


for t in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	min1 = float('inf')
	for i in range(n - 1):
		min1 = min(min1, l[i + 1] - l[i])
	print(min1)


t = int(input())
while t:
	n = int(input())
	ans = 10 ** 10
	a = list(map(int, input().split()))
	a = sorted(a)
	for i in range(len(a) - 1):
		ans = min(ans, abs(a[i] - a[i + 1]))
	print(ans)
	t = t - 1


import math
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	min = 99999999
	for i in range(n):
		for j in range(i + 1, n):
			if abs(l[i] - l[j]) < min:
				min = abs(l[i] - l[j])
	print(min)


import math
t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(0, n - 1):
		temp = a[i]
		for j in range(i + 1, n):
			b.append(abs(temp - a[j]))
	b = list(set(b))
	print(min(b))
	t = t - 1


from sys import stdin, exit
input = stdin.readline

def i():
	return input()

def ii():
	return int(input())

def iis():
	return map(int, input().split())

def liis():
	return list(map(int, input().split()))

def print_array(a):
	print(' '.join(map(str, a)))
t = ii()
for _ in range(t):
	n = ii()
	s = liis()
	s = sorted(s)
	maxi = float('inf')
	for i in range(1, len(s)):
		maxi = min(maxi, s[i] - s[i - 1])
	print(maxi)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = []
	for i in range(n - 1):
		m.append(abs(l[i] - l[i + 1]))
	print(min(m))


t = int(input(''))
for z in range(t):
	n = int(input(''))
	a = list(map(int, input('').split()))[:n]
	a.sort()
	m = 1001
	for i in range(n - 1):
		if a[i + 1] - a[i] < m:
			m = a[i + 1] - a[i]
	print(m)


t = int(input())
for l in range(t):
	n = int(input())
	minm = 999
	listx = list(map(int, input().split()))
	listx.sort()
	for m in range(n):
		if abs(listx[m] - listx[m - 1]) < minm:
			minm = abs(listx[m] - listx[m - 1])
	print(minm)


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		N = int(input())
		S = list(map(int, input().split()))
		S.sort()
		ans = float('inf')
		for i in range(1, N):
			ans = min(ans, S[i] - S[i - 1])
		print(ans)
main()


for t in range(int(input())):
	i_atlet = int(input())
	sila = [int(x) for x in input().split()]
	min_roz = max(sila)
	sila.sort(reverse=True)
	for x in range(i_atlet - 1):
		min_roz = min(min_roz, sila[x] - sila[x + 1])
	print(min_roz)


t = int(input())
for _ in range(t):
	m = 10 ** 10
	n = int(input())
	l = list(map(int, input().strip().split()))
	l.sort()
	for i in range(n - 1):
		a = l[i + 1] - l[i]
		m = min(m, a)
	print(m)


import sys
input = sys.stdin.readline
for f in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	m = s[1] - s[0]
	for i in range(n - 1):
		m = min(m, s[i + 1] - s[i])
	print(m)


import sys
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	c = sys.maxsize
	for i in range(1, n):
		if l[i] - l[i - 1] < c:
			c = l[i] - l[i - 1]
	print(c)


test = int(input())
for _ in range(test):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	if n == 2:
		print(s[1] - s[0])
	else:
		mini = s[1] - s[0]
		for i in range(1, n):
			mini = min(mini, s[i] - s[i - 1])
		print(mini)


q = int(input())
while q:
	q -= 1
	n = int(input())
	a = input().split(' ')
	for i in range(n):
		a[i] = int(a[i])
	a.sort()
	mi = 1000000000000000
	for i in range(n - 1):
		mi = min(a[i + 1] - a[i], mi)
	print(mi)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = list(map(int, input().split()))
		s.sort()
		m = 1000 * 3
		for i in range(1, n):
			diff = s[i] - s[i - 1]
			m = min(m, diff)
		print(m)
main()


a = int(input())
for i in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	c.sort()
	d = 2000
	for j in range(b - 1):
		d = min(d, c[j + 1] - c[j])
	print(d)


z = int(input())
for q in range(z):
	x = int(input())
	lst = [int(i) for i in input().split()]
	lst.sort()
	if len(lst) == 2:
		print(lst[1] - lst[0])
		continue
	s = None
	for i in range(len(lst) - 1):
		if s is None:
			s = lst[i + 1] - lst[i]
			continue
		tmp = lst[i + 1] - lst[i]
		if tmp < s:
			s = tmp
	print(s)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	arr = get_array()
	mx = 0
	arr.sort()
	res = []
	for i in range(n - 1):
		res.append(arr[i + 1] - arr[i])
	print(min(res))


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	mini = abs(a[1] - a[0])
	a.sort()
	for i in range(1, n):
		if a[i] - a[i - 1] < mini:
			mini = a[i] - a[i - 1]
	print(mini)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	count = 10 ** 9
	if len(set(arr)) != len(arr):
		print(0)
	else:
		for i in range(len(arr) - 1):
			count = min(count, arr[i + 1] - arr[i])
		print(count)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = 99999999
	for i in range(n):
		for j in range(i + 1, n):
			s = min(s, abs(l[i] - l[j]))
	print(s)


for tt in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = 999999999999999999999999999
	l.sort()
	for i in range(1, n):
		m = min(l[i] - l[i - 1], m)
	print(m)


def solve(nums, n):
	nums.sort()
	min_val = nums[1] - nums[0]
	for idx in range(1, n - 1):
		val = nums[idx + 1] - nums[idx]
		if val < min_val:
			min_val = val
	return min_val
t = int(input())
answers = []
for _ in range(t):
	n = int(input())
	nums = [int(i) for i in input().split()]
	ans = solve(nums, n)
	answers.append(ans)
for i in answers:
	print(i)


t = int(input())
answer = []
for kek in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 10 ** 10
	for i in range(n - 1):
		ans = min(ans, a[i + 1] - a[i])
	answer.append(ans)
print(*answer, sep='\n')


x = int(input())
for i in range(x):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	min = a[-1]
	for i in range(n - 1):
		s = a[i + 1] - a[i]
		if s < min:
			min = s
			mi = i
			maxi = i + 1
	print(a[maxi] - a[mi])


n = int(input())
for i in range(n):
	x = int(input())
	a = list(map(int, input().split()))
	a.sort()
	min = 1001
	for j in range(1, x):
		if a[j] - a[j - 1] < min:
			min = a[j] - a[j - 1]
	print(min)


t = int(input())
for i in range(0, t):
	l = int(input())
	k = list(map(int, input().split()))
	k.sort()
	g = []
	for j in range(0, l - 1):
		g += [k[j + 1] - k[j]]
	g.sort()
	print(g[0])


T = int(input())
while T > 0:
	N = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	diff = 9999
	for i in range(N - 1):
		if diff > arr[i + 1] - arr[i]:
			diff = arr[i + 1] - arr[i]
	print(diff)
	T -= 1


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	mindiff = s[1] - s[0]
	for i in range(n - 1):
		if abs(s[i + 1] - s[i]) < mindiff:
			mindiff = abs(s[i + 1] - s[i])
	print(mindiff)


def solve(alist):
	alist.sort()
	result = float('inf')
	for i in range(1, len(alist)):
		result = min(result, abs(alist[i] - alist[i - 1]))
	return result
t = int(input())
for _ in range(t):
	n = int(input())
	alist = list(map(int, input().split()))
	result = solve(alist)
	print(result)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = float('inf')
	for i in range(0, n - 1):
		for j in range(i + 1, n):
			if abs(l[i] - l[j]) < m:
				m = abs(l[i] - l[j])
	print(m)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	m = 100000
	for i in range(n):
		for j in range(n):
			if i != j:
				m = min(m, abs(s[i] - s[j]))
	print(m)


def answer(n, A):
	A.sort()
	mini = A[1] - A[0]
	for i in range(2, n):
		mini = min(mini, A[i] - A[i - 1])
	return mini
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(answer(n, arr))


t = int(input())
for u in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 2:
		print(abs(l[0] - l[1]))
	else:
		l.sort()
		m = 9999999999
		for i in range(n - 1, 0, -1):
			m = min(m, l[i] - l[i - 1])
		print(m)


for i in range(int(input())):
	n = int(input())
	nums = [int(x) for x in input().split()]
	nums.sort()
	hs = nums[1] - nums[0]
	for j in range(2, len(nums)):
		temp = nums[j] - nums[j - 1]
		if temp < hs:
			hs = temp
	print(hs)


for i in range(int(input())):
	n = int(input())
	jocklist = list(map(int, input().split()))
	jocklist.sort()
	print(min((abs(jocklist[j] - jocklist[j - 1]) for j in range(1, n))))


t = int(input())
for i in range(t):
	input()
	arr = [int(x) for x in input().split()]
	list.sort(arr)
	arrr = [arr[i + 1] - arr[i] for i in range(len(arr) - 1)]
	print(min(arrr))
5


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set(a)
	if len(list(s)) != len(a):
		print(0)
	else:
		a.sort()
		min = 10000
		for i in range(1, n):
			d = a[i] - a[i - 1]
			if min > d:
				min = d
		print(min)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		s = invr()
		s = sorted(s)
		min_val = s[-1]
		for i in range(n - 1):
			min_val = min(min_val, s[i + 1] - s[i])
		print(min_val)
main()


MAX = 1000
tests = []
tests_count = int(input())
for _ in range(0, tests_count):
	input()
	tests.append(sorted((int(i) for i in input().split(' '))))
for test in tests:
	minimum = MAX
	for i in range(0, len(test) - 1):
		minimum_temp = abs(test[i] - test[i + 1])
		if minimum_temp < minimum:
			minimum = minimum_temp
	print(minimum)


for _ in range(0, int(input())):
	n = int(input())
	strs = list(map(int, input().split()))
	strs.sort()
	diff = strs[1] - strs[0]
	for i in range(2, n):
		if strs[i] - strs[i - 1] < diff:
			diff = strs[i] - strs[i - 1]
	print(diff)


t = int(input())
for _ in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	array.sort()
	min1 = 10 ** 9
	for i in range(1, n):
		min1 = min(min1, array[i] - array[i - 1])
	print(min1)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	b = []
	for j in range(n - 1):
		b.append(abs(s[j] - s[j + 1]))
	print(min(b))


entry = eval(input())
compare = 0
compareMin = 1000
final = []
for e in range(entry):
	atleta = eval(input())
	strg = input()
	strg = [int(x) for x in strg.split()]
	for o in range(len(strg)):
		for j in range(len(strg)):
			if o != j:
				if strg[o] - strg[j] < 0:
					compare = (strg[o] - strg[j]) * -1
				else:
					compare = strg[o] - strg[j]
				if compare < compareMin:
					compareMin = compare
	final.append(compareMin)
	compareMin = 1000
for t in range(len(final)):
	print(final[t])


def solve(numbers, size):
	numbers.sort(reverse=True)
	check = set(numbers)
	if len(check) < len(numbers):
		print(0)
	else:
		diff = 1000
		for x in range(1, size):
			diff = min(numbers[x - 1] - numbers[x], diff)
		print(diff)
for _ in range(int(input())):
	size = int(input())
	solve(list(map(int, input().split())), size)


import sys

def minDiff(arr):
	if len(arr) == 2:
		print(abs(abs(arr[0]) - abs(arr[1])))
	else:
		arr.sort()
		minD = abs(abs(arr[0]) - abs(arr[1]))
		for i in range(1, len(arr) - 1):
			newM = abs(abs(arr[i]) - abs(arr[i + 1]))
			minD = min(minD, newM)
		print(minD)
n = int(input())
for i in range(n):
	num = int(input())
	arr = list(map(int, sys.stdin.readline().strip().split()))
	minDiff(arr)


import math
t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split(' ')))
	s = sorted(s)
	mini = max(s)
	for j in range(n - 1):
		if s[j + 1] - s[j] < mini:
			mini = s[j + 1] - s[j]
	print(mini)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mi = 10 ** 20
	if len(set(a)) != n:
		print('0')
	else:
		a.sort()
		for i in range(n - 1):
			x = a[i + 1] - a[i]
			if x < mi:
				mi = x
		print(mi)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	a = 10000000000
	for i in range(n - 1):
		b = s[i + 1] - s[i]
		a = min(a, b)
	print(a)


z = int(input())
for i in range(0, z):
	b = int(input())
	x = list(map(int, input().split()))
	x.sort()
	s = x[1] - x[0]
	for j in range(2, b):
		d = x[j] - x[j - 1]
		if d < s:
			s = d
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	mindiff = arr[1] - arr[0]
	for i in range(len(arr) - 1):
		mindiff = min(mindiff, arr[i + 1] - arr[i])
	print(mindiff)


num = int(input())
for _ in range(num):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	min_ = 1e+19
	for i in range(1, n):
		a = l[i - 1]
		b = l[i]
		min_ = min(min_, abs(a - b))
	print(min_)


t = int(input())
while t > 0:
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	l = []
	for i in range(1, n):
		l.append(ar[i] - ar[i - 1])
	print(min(l))
	t -= 1


def honestcoach(n, a):
	mini = 100000
	a.sort()
	for i in range(n - 1):
		sub = a[i + 1] - a[i]
		mini = min(mini, sub)
	return mini
test = int(input())
for i in range(test):
	n = int(input())
	a = list(map(int, input().split()))
	print(honestcoach(n, a))


def solve():
	n = int(input())
	strength = list(map(int, input().split()))
	strength.sort()
	min_diff = float('inf')
	for i in range(1, n):
		min_diff = min(min_diff, strength[i] - strength[i - 1])
	print(min_diff)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	left = 10 ** 8
	for j in range(n - 1):
		temp = s[j + 1] - s[j]
		if left > temp:
			left = temp
	print(left)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	i = 0
	j = 1
	m = s[j] - s[i]
	if n == 2:
		print(s[1] - s[0])
		continue
	while j < n - 1:
		if s[j + 1] - s[i + 1] < m:
			m = s[j + 1] - s[i + 1]
		i += 1
		j += 1
	print(m)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	diff = a[0] - a[1]
	for i in range(0, n - 1):
		diff = min(diff, a[i] - a[i + 1])
	print(diff)


import math
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	c = []
	for x in range(n - 1):
		c.append(a[x + 1] - a[x])
	print(min(c))


for _ in range(int(input())):
	n = int(input())
	strn = list(map(int, input().split()))
	strn = sorted(strn)
	d = strn[1] - strn[0]
	for i in range(n - 1):
		if strn[i + 1] - strn[i] < d:
			d = strn[i + 1] - strn[i]
	print(d)


for u in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = 10 ** 10
	for i in range(1, n):
		x = l[i] - l[i - 1]
		m = min(m, x)
	print(m)


import math
import sys
from collections import deque
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	if len(s) != len(set(s)):
		print(0)
	else:
		r = min((abs(s[i] - s[j]) for i in range(len(s)) for j in range(i)))
		print(r)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))
cases = inp()
for case in range(cases):
	n = inp()
	nums = inlt()
	nums.sort()
	min_dif = nums[-1]
	for (index, num) in enumerate(nums):
		if index == 0:
			continue
		min_dif = min(abs(num - nums[index - 1]), min_dif)
	print(min_dif)


from math import *
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	d = 1001
	for j in range(len(l) - 1):
		if l[j + 1] - l[j] < d:
			d = l[j + 1] - l[j]
	print(d)


t = int(input())
for _ in range(t):
	n = int(input())
	ar = sorted(list(map(int, input().split())))
	ans = 10001
	for i in range(0, n - 1):
		if ar[i + 1] - ar[i] < ans:
			ans = ar[i + 1] - ar[i]
	print(ans)


import sys, math
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, sys.stdin.readline().split()))
	l.sort()
	a = 10000
	for i in range(1, n):
		a = min(a, l[i] - l[i - 1])
	print(a)


t = int(input())
while t:
	t -= 1
	l = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = float('inf')
	for i in range(l - 1):
		b = min(a[i + 1] - a[i], b)
	print(b)


for x in range(int(input())):
	q = int(input())
	l = sorted(list(map(int, input().split())))
	m = 0
	t = 0
	for i in range(q):
		if i == 1:
			m = l[i] - l[i - 1]
			t = m
		elif i > 1:
			m = l[i] - l[i - 1]
			if t >= m:
				t = m
	print(t)


t = int(input())
for i in range(t):
	n = int(input())
	players = sorted(list(map(int, input().split())))
	mini = 9999999
	for j in range(1, n):
		new_min = abs(players[j] - players[j - 1])
		if new_min == 0:
			mini = new_min
			break
		elif mini > new_min:
			mini = new_min
	print(mini)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	diff = [a[i] - a[i - 1] for i in range(1, n)]
	k = 0
	m = max(a) - min(a)
	for i in range(n - 1):
		if diff[i] < m:
			m = diff[i]
			k = i
	print(diff[k])


for t in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	m = 1000
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < m:
			m = arr[i + 1] - arr[i]
	print(m)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().rstrip().split()))[:n]
	l.sort()
	mini = abs(l[0] - l[1])
	for i in range(1, len(l) - 1):
		d = abs(l[i] - l[i + 1])
		if mini > d or d == 0:
			mini = d
	print(mini)


def min_difference(arr):
	arr.sort()
	diff = arr[1] - arr[0]
	for i in range(1, len(arr)):
		if arr[i] - arr[i - 1] < diff:
			diff = arr[i] - arr[i - 1]
	return diff
n = int(input())
while n != 0:
	a = input()
	arr = [int(x) for x in input().split()]
	print(min_difference(arr))
	n -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	if len(s) != len(set(s)):
		print(0)
	else:
		s = sorted(s)
		res = s[1] - s[0]
		for i in range(1, n):
			if res > s[i] - s[i - 1]:
				res = s[i] - s[i - 1]
		print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	mi = 1000000
	lol = [int(n) for n in input().split()]
	for i in lol:
		z = lol.copy()
		z.remove(i)
		for j in z:
			if abs(i - j) < mi:
				mi = abs(i - j)
	print(mi)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for i in range(t):
	inp()
	st = inlt()
	st = sorted(st)
	maxdiff = 100000
	for j in range(len(st) - 1):
		maxdiff = min(abs(st[j] - st[j + 1]), maxdiff)
	print(maxdiff)


t = int(input())
for t in range(t):
	q = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	q1 = max(lst)
	for i in range(len(lst) - 1):
		if q1 > lst[i + 1] - lst[i]:
			q1 = lst[i + 1] - lst[i]
	print(q1)


teams = int(input())
for team in range(teams):
	n = int(input())
	people = [int(x) for x in input().split(' ')]
	people.sort()
	result = people[1] - people[0]
	for x in range(len(people) - 2):
		current = people[x + 2] - people[x + 1]
		if current < result:
			result = current
	print(result)


import os, sys
t = int(input())
for nc in range(t):
	n = int(input())
	s = sorted([int(x) for x in input().strip().split()])
	flag = False
	ans = s[-1] - s[0]
	for i in range(n - 1):
		ans = min(ans, s[i + 1] - s[i])
	print(ans)


T = int(input())
for i in range(0, T):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	ans = A[1] - A[0]
	for j in range(1, n):
		t = A[j] - A[j - 1]
		if t < ans:
			ans = t
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	aa = []
	a = [int(i) for i in input().split()]
	for i in range(n - 1, -1, -1):
		for j in range(i):
			aa.append(abs(a[i] - a[j]))
	print(min(aa))


t = int(input())

def findMinDiff(arr, n):
	arr = sorted(arr)
	diff = 10 ** 20
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < diff:
			diff = arr[i + 1] - arr[i]
	return diff
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	l = len(arr)
	print(findMinDiff(arr, l))


t = int(input())
for t_itr in range(t):
	a = int(input())
	drives = list(map(int, input().rstrip().split()))
	eli = sorted(drives)
	val = 1000000000.0
	for i in range(1, a):
		val = min(val, eli[i] - eli[i - 1])
	print(val)


t = int(input())
for test in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ls = []
	for i in range(n - 1):
		p = abs(l[i] - l[i + 1])
		ls.append(p)
	print(min(ls))


t = int(input())
cnt = 0
while cnt < t:
	cnt += 1
	n = int(input())
	a = [int(i) for i in input().split()]
	a = sorted(a)
	base = abs(a[1] - a[0])
	for i in range(2, n):
		if abs(a[i] - a[i - 1]) < base:
			base = abs(a[i] - a[i - 1])
	print(base)


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	r = float('inf')
	for i in range(n - 1):
		if l[i + 1] - l[i] < r:
			r = l[i + 1] - l[i]
	print(r)


for i in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	s = 50000000
	for j in range(len(l) - 1):
		a = l[j + 1] - l[j]
		if a < s:
			s = a
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = abs(a[1] - a[0])
	for i in range(2, len(a)):
		ans = min(ans, abs(a[i] - a[i - 1]))
	print(ans)


n = int(input())

def solve(mems):
	mems.sort()
	minVals = []
	for x in range(len(mems) - 1):
		minVals.append(abs(mems[x] - mems[x + 1]))
	return min(minVals)
for x in range(n):
	i = input()
	print(solve(list(map(int, input().split()))))


import math
try:
	t = int(input())
	while t:
		n = int(input())
		l = list(map(int, input().split()))[:n]
		m = []
		for i in range(n - 1):
			m1 = max(l)
			l.remove(m1)
			m2 = max(l)
			m.append(abs(m1 - m2))
		print(min(m))
except:
	pass


from sys import stdin
_input = stdin.readline
(_int, _sorted, _range) = (int, sorted, range)

def solution():
	for _ in _range(_int(_input())):
		n = _int(_input())
		arr = _sorted([_int(i) for i in _input().split()])
		delta = arr[n - 1]
		for i in _range(n - 1):
			if arr[i + 1] - arr[i] < delta:
				delta = arr[i + 1] - arr[i]
		print(delta)
solution()


x = int(input())
for i in range(x):
	n = int(input())
	l = [int(k) for k in input().split()][:n]
	a = 10000
	s = []
	for j in range(n - 1):
		for r in range(j + 1, n):
			a = abs(l[j] - l[r])
			s.append(a)
	print(min(s))


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	k = max(a) - min(a)
	for i in range(n - 1):
		if k > a[i + 1] - a[i]:
			k = a[i + 1] - a[i]
	print(k)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = len(l)
	if m >= 2:
		k = l
		k.sort()
		g = []
		for i in range(m - 1):
			d = abs(l[i + 1] - l[i])
			g.append(d)
		f = min(g)
		a = g.index(f)
		print(f)


def f(A):
	A.sort()
	d = A[1] - A[0]
	for i in range(len(A) - 1):
		if d > A[i + 1] - A[i]:
			d = A[i + 1] - A[i]
	return d
t = int(input())
for i in range(t):
	n = input()
	S = input().split(' ')
	A = []
	for i in S:
		A.append(int(i))
	print(f(A))


import sys

def get_optimal_value(athletes: list) -> int:
	athletes.sort()
	return min([athletes[i + 1] - athletes[i] for i in range(len(athletes) - 1)])
for line in sys.stdin:
	if ' ' in line:
		athletes = list(map(int, line.split(' ')))
		print(get_optimal_value(athletes))


for _ in range(int(input())):
	n = int(input())
	data = [int(x) for x in input().split()]
	data.sort()
	ans = 100000000
	for q in range(n - 1):
		temp = abs(data[q] - data[q + 1])
		if temp < ans:
			ans = temp
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	m = 1000000
	for i in range(n - 1):
		if a[i + 1] - a[i] < m:
			m = a[i + 1] - a[i]
	print(m)


import sys
infile = sys.stdin
next(infile)
for line in infile:
	n = int(line)
	l = list(map(int, infile.readline().split()))
	diff = 1000000000
	for i in range(n):
		for j in range(n):
			if i != j:
				if abs(l[i] - l[j]) < diff:
					diff = abs(l[i] - l[j])
	print(diff)


t = int(input())
for cnt in range(t):
	n = int(input())
	L = list(map(int, input().split()))
	L.sort()
	res = 10 ** 9
	for i in range(1, len(L)):
		res = min(res, L[i] - L[i - 1])
	print(res)


import math
from sys import stdin, stdout

def L():
	return list(map(int, stdin.readline().split()))

def Si():
	return sorted(list(map(int, stdin.readline().split())))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def main():
	for i in range(I()):
		n = I()
		l = Si()
		min = 1000
		for i in range(n):
			if i != 0 and l[i] - l[i - 1] < min:
				min = l[i] - l[i - 1]
		print(min)
main()


import sys
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = sys.maxsize
	for i in range(n - 1):
		ans = min(ans, abs(l[i] - l[i + 1]))
	print(ans)


test = int(input())
for i in range(test):
	nu = int(input())
	l = list(map(int, input().rstrip().split()))
	l.sort()
	m = 1999999999
	for i in range(0, len(l) - 1):
		if m > l[i + 1] - l[i]:
			m = l[i + 1] - l[i]
	print(m)


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	n = ri()
	S = sorted(rl())
	print(min([S[i] - S[i - 1] for i in range(1, n)]))
mode = 'T'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


def sol(arr):
	m = arr[0] - arr[1]
	for i in range(1, len(arr) - 1):
		if arr[i] - arr[i + 1] < m:
			m = arr[i] - arr[i + 1]
	print(m)
d = int(input())
for i in range(0, d):
	j = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	sol(l)


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	s = l[n - 1]
	for i in range(n - 1):
		if l[i + 1] - l[i] < s:
			s = l[i + 1] - l[i]
	print(s)


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	m = 99999999999
	for i in range(1, n):
		m = min(m, l[i] - l[i - 1])
	print(m)


for q in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	B = a[-1]
	A = a[-2]
	res = abs(A - B)
	for i in range(n - 1, 0, -1):
		B = a[i]
		A = a[i - 1]
		res = min(res, abs(A - B))
	print(res)


t = int(input())
for i in range(0, t):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	m = abs(l[0] - l[1])
	for j in range(2, n):
		if abs(l[j] - l[j - 1]) < m:
			m = abs(l[j] - l[j - 1])
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	array1 = list(map(int, input().split(' ')))
	array1.sort()
	list1 = []
	for j in range(1, n):
		list1.append(array1[j] - array1[j - 1])
	list1.sort()
	print(list1[0])


t = int(input())
for test in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	min_ = 10 ** 9
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < min_:
			min_ = arr[i + 1] - arr[i]
		if min_ == 0:
			break
	print(min_)


for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	a.sort()
	jg = 99999999
	for i in range(1, n):
		jg = min(jg, a[i] - a[i - 1])
	print(jg)


t = int(input())
for q in range(0, t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	diff = 1000000
	for i in range(1, n):
		s = a[i] - a[i - 1]
		if s < diff:
			diff = s
	print(diff)


def sortir(n, a):
	a.sort()
	minimum = a[n - 1]
	for i in range(1, n):
		minimum = min(minimum, abs(a[i] - a[i - 1]))
	return minimum
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(sortir(n, a))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	ans = 10000
	arr.sort()
	for i in range(1, n):
		ans = min(ans, arr[i] - arr[i - 1])
	print(ans)


t = int(input())
for i in range(t):
	k = input()
	a = sorted(list(map(int, input().split())))
	rez = []
	for i in range(len(a) - 1):
		rez.append(a[i + 1] - a[i])
	print(min(rez))


def f(al):
	al.sort()
	minn = 10000000000
	for i in range(len(al) - 1):
		minn = min(minn, al[i + 1] - al[i])
	return minn
for tc in range(int(input())):
	temp = input()
	ll = list(map(int, input().split()))
	print(f(ll))


import math

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
t = inp()
while t:
	n = inp()
	a = inlist()
	d = 100000
	for i in range(n - 1):
		for j in range(i + 1, n):
			d = min(abs(a[i] - a[j]), d)
	print(d)
	t -= 1


n = int(input())
for i in range(n):
	h = int(input())
	f = list(map(int, input().split()))
	f.sort()
	mini = f[-1] - f[0]
	for j in range(h - 1):
		for k in range(j + 1, h):
			if f[k] - f[j] < mini:
				mini = f[k] - f[j]
	print(mini)


for _ in range(int(input())):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	b = []
	for i in range(n - 1):
		b.append(abs(s[i] - s[i + 1]))
	print(min(b))


t = int(input())
for j in range(t):
	n = int(input())
	s = list(map(int, input().split(' ')))
	s.sort()
	m = max(s)
	for i in range(1, n):
		if s[i] - s[i - 1] < m:
			m = s[i] - s[i - 1]
	print(m)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mn = a[1] - a[0]
	for i in range(1, n - 1):
		s = a[i + 1] - a[i]
		if s < mn:
			mn = s
	print(mn)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = l[n - 1]
	for i in range(1, n):
		dif = l[i] - l[i - 1]
		ans = min(ans, dif)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	strength = list(map(int, input().split()))
	strength.sort(reverse=True)
	if n == 2:
		print(strength[0] - strength[1])
	else:
		ans = 99999999
		for i in range(n - 1):
			if strength[i] - strength[i + 1] < ans:
				ans = strength[i] - strength[i + 1]
		print(ans)


for _ in range(int(input())):
	x = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	m = 99999999999999
	for i in range(1, x):
		m = min(l[i - 1] - l[i], m)
	print(m)


test = int(input())
for i in range(test):
	n = int(input())
	arr = [int(i) for i in input().split()]
	ans = float('inf')
	for i in range(n - 1):
		res = float('inf')
		for j in range(i + 1, n):
			res = min(res, abs(arr[i] - arr[j]))
		ans = min(ans, res)
	print(ans)


def findMinDiff(arr, n):
	diff = max(arr)
	for i in range(n - 1):
		for j in range(i + 1, n):
			if abs(arr[i] - arr[j]) < diff:
				diff = abs(arr[i] - arr[j])
	return diff
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	if len(s) > 2:
		s.sort()
		maior = max(s)
		for i in range(len(s) - 1):
			if abs(s[i] - s[i + 1]) < maior:
				maior = abs(s[i] - s[i + 1])
		print(maior)
	else:
		print(max(s) - min(s))


for _ in range(int(input())):
	n = int(input())
	lst = sorted(list(map(int, input().split())))
	(a, b, c) = (0, 0, 0)
	l = []
	for (i, j) in enumerate(range(n - 1)):
		l.append(lst[i + 1] - lst[i])
	print(min(l))


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	ms = 1001
	for i in range(1, n):
		ms = min(a[i] - a[i - 1], ms)
	print(ms)


from sys import stdin, stdout
inp = int(stdin.readline())
arr = []
for i in range(inp * 2):
	players = stdin.readline().split()
	if len(players) == 1:
		continue
	else:
		team = [int(i) for i in players]
		arr.append(team)

def find_strength():
	for i in arr:
		i.sort()
		low = i[1] - i[0]
		prev = i[0]
		for play in range(1, len(i)):
			low = min(low, i[play] - prev)
			prev = i[play]
		print(low)
find_strength()


for j in range(int(input())):
	t = 1001
	a = int(input())
	s1 = list(map(int, input().split()))
	s = sorted(s1)
	for i in range(a - 1):
		if abs(s[i] - s[i + 1]) < t:
			t = abs(s[i] - s[i + 1])
	print(t)


from operator import itemgetter
from collections import Counter
from collections import deque
import queue as Q
import math as m
import copy as c

def solution():
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	arr.sort()
	mi = m.inf
	for i in range(1, n):
		val = arr[i] - arr[i - 1]
		mi = min(val, mi)
	print(mi)
T = int(input())
for _ in range(T):
	solution()


def read_arr():
	return [int(x) for x in input().split()]
N_SETS = int(input())
for i in range(N_SETS):
	_ = int(input())
	a = read_arr()
	a.sort()
	res = float('inf')
	for i in range(1, len(a)):
		delta = a[i] - a[i - 1]
		if delta < res:
			res = delta
	print(res)


import sys
data = []
for line in sys.stdin:
	content = []
	for x in line.split():
		content.append(int(x))
	data.append(content)
for k in range(data[0][0]):
	case = data[2 * k + 2]
	case.sort()
	min = case[1] - case[0]
	for j in range(len(case) - 1):
		if case[j + 1] - case[j] < min:
			min = case[j + 1] - case[j]
	print(min)


a = int(input())
for i in range(a):
	b = int(input())
	c = [int(x) for x in input().split()]
	c.sort()
	minn = c[1] - c[0]
	for j in range(1, b):
		if c[j] - c[j - 1] < minn:
			minn = c[j] - c[j - 1]
	print(minn)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	print(min([arr[i + 1] - arr[i] for i in range(n - 1)]))


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	ans = 10000
	for i in range(1, n):
		ans = min(ans, abs(A[i] - A[i - 1]))
	print(ans)


n = int(input())
for i in range(n):
	num = int(input())
	k = [int(x) for x in input().split()]
	k.sort()
	l = []
	for j in range(num - 1):
		a = abs(k[j] - k[j + 1])
		l.append(a)
	print(min(l))


n = int(input())
c = []
for i in range(n):
	x = int(input())
	a = list(map(int, input().split()))
	if len(list(set(a))) != len(a):
		c.append(0)
	else:
		a.sort()
		x = a[1] - a[0]
		flag = 0
		for i in range(1, len(a) - 1):
			if a[i + 1] - a[i] == 1:
				c.append(1)
				flag = 1
				break
			elif x > a[i + 1] - a[i]:
				x = a[i + 1] - a[i]
		if flag == 0:
			c.append(x)
for i in c:
	print(i)


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	mn = 10000
	for j in range(len(arr)):
		for k in range(j + 1, len(arr)):
			mn = min(mn, abs(arr[j] - arr[k]))
	print(mn)


def Checking(n, store):
	if n == 1:
		return 0
	store.sort()
	minimum = 100000
	for i in range(1, n):
		k = store[i] - store[i - 1]
		if k < minimum:
			minimum = k
	return minimum
for t in range(int(input())):
	n = int(input())
	store = list(map(int, input().split()))
	result = Checking(n, store)
	print(result)


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().strip().split()))[:n]
	arr.sort()
	min1 = 9999999999999999
	for i in range(1, n):
		min1 = min(min1, arr[i] - arr[i - 1])
	print(min1)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	res = 10000000000
	for i in range(n):
		for j in range(n):
			if i != j:
				temp = abs(l[i] - l[j])
				if temp < res:
					res = temp
	print(res)


import sys
from math import ceil, sqrt, sin, pi, tan
from collections import defaultdict
read = sys.stdin.buffer.readline
import heapq
mi = lambda : map(int, read().split())
li = lambda : list(mi())
cin = lambda : int(read())

def isp(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
ps = lambda x: x == pow(int(sqrt(x)), 2)
for _t in range(cin()):
	n = cin()
	a = li()
	a.sort()
	mn = a[-1]
	for i in range(1, n):
		mn = min(mn, a[i] - a[i - 1])
	print(mn)


from collections import defaultdict, Counter
from functools import lru_cache
from heapq import heappush, heappop
from math import gcd, floor, ceil
from sys import stdin, stdout

def ilist():
	return [int(x) for x in stdin.readline().strip().split(' ')]

def iint():
	return int(stdin.readline().strip())

def istr():
	return stdin.readline().strip()

def solve(s):
	n = len(s)
	res = float('inf')
	s.sort()
	for i in range(1, n):
		res = min(res, s[i] - s[i - 1])
	return res
t = iint()
for _ in range(t):
	n = iint()
	s = ilist()
	print(solve(s))


for _ in range(int(input())):
	n = int(input())
	s = sorted(map(int, input().split()))
	a = 9000000000.0
	for i in range(1, n):
		a = min(a, s[i] - s[i - 1])
	print(a)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = sorted(array())
	d = min((a[i] - a[i - 1] for i in range(1, n)))
	print(d)


t = int(input())
for i in range(t):
	n = int(input())
	str1 = input()
	list1 = list(map(int, str1.split()))
	list1.sort()
	list2 = ['']
	m = 0
	while m < len(list1) - 1:
		list2.append(list1[m + 1] - list1[m])
		m = m + 1
	list2 = list2[1:]
	print(min(list2))


import math
for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	arr.sort()
	res = 100001
	for j in range(1, n):
		if arr[j] - arr[j - 1] < res:
			res = arr[j] - arr[j - 1]
	print(res)


def parse():
	tests = int(input())
	for t in range(tests):
		n = int(input())
		strengths = [int(num) for num in input().split()]
		minStrength(strengths)

def minStrength(s):
	s.sort()
	minValue = float('inf')
	for i in range(len(s) - 1):
		minValue = min(minValue, abs(s[i] - s[i + 1]))
	print(minValue)
parse()


t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	ans = 10 ** 20
	for i in range(1, n):
		if ar[i] - ar[i - 1] < ans:
			ans = ar[i] - ar[i - 1]
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	l = []
	s.sort()
	for j in range(n - 1):
		a = s[j + 1] - s[j]
		l.append(a)
	l.sort()
	print(l[0])


n = int(input())
for i in range(n):
	m = int(input())
	l = list(map(int, input().split()))
	l.sort()
	s = 1000
	for i in range(len(l) - 1):
		if l[i + 1] - l[i] < s:
			s = l[i + 1] - l[i]
	print(s)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = 1000
	for i in range(n - 1):
		ans = min(ans, s[i + 1] - s[i])
	print(ans)


for i in range(int(input())):
	a = int(input())
	b = sorted([int(i) for i in input().split()])
	m = 10000000000000000
	for j in range(a - 1):
		c = abs(b[j] - b[j + 1])
		if c <= m:
			m = c
	print(m)


num_lines = int(input())
lineList = [input() for i in range(num_lines * 2)]
for line in lineList[1::2]:
	line = [int(i) for i in line.split()]
	line = sorted(line)
	mini = line[1] - line[0]
	for (ind, num) in enumerate(line[2:]):
		if mini == 0:
			break
		test_mini = num - line[ind + 1]
		if test_mini < mini:
			mini = test_mini
	print(mini)


def honestCoach(inputList):
	inputList.sort()
	a = []
	for i in range(1, len(inputList)):
		a.append(inputList[i] - inputList[i - 1])
	print(min(a))
testcases = int(input())
while testcases:
	a = int(input())
	inp = list(map(int, input().split()))
	honestCoach(inp)
	testcases -= 1


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = 9999999999999
	for i in range(n - 1):
		if m > l[i + 1] - l[i]:
			m = l[i + 1] - l[i]
	print(m)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	res = 100000000
	for i in range(n):
		if i == n - 1:
			continue
		res = min(res, abs(a[i] - a[i + 1]))
	print(res)


t = int(input())
for _ in range(t):
	l = int(input())
	a = list(map(int, input().split()))
	s = list(set(a))
	f = 0
	for x in s:
		if a.count(x) > 1:
			print(0)
			f = 1
			break
	if f == 0:
		a.sort(reverse=True)
		md = a[0] - a[1]
		for i in range(l):
			for j in range(l):
				if abs(a[i] - a[j]) > 0 and abs(a[i] - a[j]) < md:
					md = abs(a[i] - a[j])
		print(md)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))[:n]
	a.sort()
	min_diff = abs(a[0] - a[1])
	for j in range(n - 1):
		if min_diff > abs(a[j] - a[j + 1]):
			min_diff = abs(a[j] - a[j + 1])
	print(min_diff)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mn = 234567899
	for i in range(0, n - 1):
		if l[i + 1] - l[i] < mn:
			mn = l[i + 1] - l[i]
	print(mn)


t = int(input())
for z in range(t):
	n = int(input())
	s = sorted(map(int, input().split()))
	print(min((abs(s[i] - s[i + 1]) for i in range(n - 1))))


from sys import stdin, stdout
import collections
import heapq
import itertools
import functools
import math
import operator

def read_line():
	return stdin.readline().strip()

def read_int():
	return int(read_line())

def read_arr():
	return read_line().split(' ')

def read_int_arr():
	return [int(x) for x in read_arr()]

def query_interactive(s):
	print(s)
	stdout.flush()

def main():
	T = 1
	T = read_int()
	for _ in range(T):
		n = read_int()
		S = read_int_arr()
		S.sort()
		res = float('inf')
		for i in range(n - 1):
			res = min(res, S[i + 1] - S[i])
		print(res)
main()


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()

def test():
	s = int(input())
	n = sorted(list(map(int, input().split())), reverse=True)
	d = n[0]
	for i in range(1, s):
		if abs(n[i - 1] - n[i]) < d:
			d = abs(n[i - 1] - n[i])
	return d
t = int(input())
for _ in range(t):
	print(test())


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		athletes = list(map(int, input().split()))
		athletes.sort()
		difference = abs(athletes[0] - athletes[1])
		for i in range(len(athletes) - 1):
			for j in range(i + 1, len(athletes)):
				if abs(athletes[i] - athletes[j]) < difference:
					difference = abs(athletes[i] - athletes[j])
		print(difference)
main()


N = int(input())
answers = []
for i in range(N):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	rng = 1001
	for k in range(1, len(arr)):
		if arr[k] - arr[k - 1] < rng:
			rng = arr[k] - arr[k - 1]
	answers.append(rng)
for i in answers:
	print(i)


from math import ceil
t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	s = x.split()
	for i in range(len(s)):
		s[i] = int(s[i])
	s.sort()
	d = []
	for i in range(len(s) - 1):
		d.append(s[i + 1] - s[i])
	print(min(d))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	minn = a[1] - a[0]
	for j in range(len(a) - 1):
		if minn > a[j + 1] - a[j]:
			minn = a[j + 1] - a[j]
	print(minn)


t = int(input())
for _ in range(t):
	n = int(input())
	list1 = list(map(int, input().split()))
	list1 = sorted(list1)
	mini = list1[1] - list1[0]
	for i in range(2, n):
		temp = list1[i] - list1[i - 1]
		if temp < mini:
			mini = temp
	print(mini)


import math

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		m = 10 ** 18
		for i in range(n):
			for j in range(i + 1, n):
				if m > abs(a[i] - a[j]):
					m = abs(a[i] - a[j])
		print(m)
main()


t = int(input())
for testcase in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	difference = s[1] - s[0]
	for i in range(1, n - 1):
		difference = min(difference, s[i + 1] - s[i])
	print(difference)


def solve(n, s):
	s.sort()
	result = float('inf')
	for i in range(1, n):
		result = min(result, abs(s[i] - s[i - 1]))
	return result
for i in range(int(input())):
	n = int(input())
	s = [int(x) for x in input().split()]
	print(solve(n, s))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	res = -1
	for i in range(n):
		for j in range(n):
			if i == j:
				continue
			if res == -1 or abs(arr[i] - arr[j]) < res:
				res = abs(arr[i] - arr[j])
	print(res)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	val = 10 ** 9
	for i in range(n - 1):
		val = min(val, abs(l[i] - l[i + 1]))
	print(val)


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	m = l[-1] - l[-2]
	for i in range(n - 2):
		x = l[i + 1] - l[i]
		if m > x:
			m = x
		if m == 0:
			break
	print(m)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	minimum = 100000000
	x = []
	for i in range(n - 1):
		diff = l[i + 1] - l[i]
		x.append(diff)
	print(min(x))


total_input = int(input())
for i in range(0, total_input):
	number_athletes = int(input())
	total_athletes = []
	Minimum = 100000
	athletes = list(map(int, input().split()))
	athletes.sort()
	for s in range(1, len(athletes)):
		result = int(athletes[s]) - int(athletes[s - 1])
		if result < Minimum:
			Minimum = result
	print(Minimum)


t = int(input())
for i in range(t):
	n = int(input())
	a = map(int, input().split())
	a = sorted(a)
	print(min((a[k] - a[k - 1] for k in range(1, n))))


import math
TT = int(input())
for _ in range(TT):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	diff = math.inf
	for i in range(1, n):
		this = l[i] - l[i - 1]
		diff = min(this, diff)
	print(diff)


t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	solution = 999
	for i in range(n - 1):
		solution = min(solution, s[i + 1] - s[i])
	print(solution)


T = int(input())
for _ in range(T):
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort()
	ans = max(ls)
	for i in range(len(ls) - 1):
		diff = abs(ls[i] - ls[i + 1])
		if diff < ans:
			ans = diff
	print(ans)


t = int(input())
for tes in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 10 ** 10
	for i in range(1, n):
		ans = min(ans, arr[i] - arr[i - 1])
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	Aa = 99999999
	for i in range(1, len(A)):
		Aa = min(Aa, A[i] - A[i - 1])
	print(Aa)
	t -= 1


t = int(input())
a = []
for i in range(t):
	n = int(input())
	a.append([int(i) for i in input().split()])
for item in a:
	min_diff = 1000
	n = len(item)
	for j in range(n):
		for k in range(j + 1, n):
			diff = abs(item[j] - item[k])
			if diff < min_diff:
				min_diff = diff
	print(min_diff)


t = int(input())
for i in range(t):
	n = int(input())
	data = sorted(map(int, input().split()))
	print(min([data[i] - data[i - 1] for i in range(1, n)]))


def two(a):
	m = a[-1]
	for i in range(1, len(a)):
		m = min(m, a[i] - a[i - 1])
		if m == 0:
			return 0
	return m
t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	print(two(a))


def play(arr):
	diff = 9999999999999999
	for i in range(len(arr)):
		for j in range(i + 1, len(arr)):
			if abs(arr[i] - arr[j]) < diff:
				diff = abs(arr[i] - arr[j])
	return diff
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	out = play(arr)
	print(out)


def read_ints():
	return [int(i) for i in input().strip().split()]
t = int(input())
for i in range(t):
	input()
	nums = read_ints()
	nums.sort()
	ans = 10000
	for idx in range(1, len(nums)):
		ans = min(ans, nums[idx] - nums[idx - 1])
	print(ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = list(map(int, input().rstrip().split()))
	s.sort()
	team1 = list()
	team2 = list()
	min_diff = max(s)
	for i in range(len(s) - 1):
		if abs(s[i] - s[i + 1]) < min_diff:
			min_diff = abs(s[i] - s[i + 1])
			min_val = [s[i], s[i + 1]]
	team1.append(max(min_val))
	team2.append(min(min_val))
	print(abs(max(team1) - min(team2)))


def myfunction(nnn):
	answet = []
	for i in range(1, len(nnn)):
		demo1 = nnn[0:i]
		demo2 = nnn[i:len(nnn)]
		answet.append(abs(max(demo1) - min(demo2)))
	print(min(answet))
n = int(input())
for i in range(n):
	nn = int(input())
	nnn = [*map(int, str(input()).split(' '))]
	bb = [myfunction(sorted(nnn))]
	if nn == len(bb):
		for i in bb:
			print(bb)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	l = []
	for i in range(n - 1):
		l.append(abs(a[i + 1] - a[i]))
	l.sort()
	print(l[0])


t = int(input())
for _ in range(t):
	input()
	li = sorted(list(map(int, input().split())))
	for i in range(len(li) - 1):
		li[i] = int(abs(int(li[i + 1] - li[i])))
	print(min(li))


for _ in range(int(input())):
	n = int(input())
	arr = list(sorted(map(int, input().split())))
	md = 1000
	for i in range(1, n):
		md = min(md, abs(arr[i] - arr[i - 1]))
	print(md)


n = int(input())
while n > 0:
	m = int(input())
	l = []
	l = input().split(' ')
	l1 = [int(i) for i in l]
	l2 = sorted(l1)
	l3 = [l2[i + 1] - l2[i] for i in range(0, len(l2) - 1)]
	l3.append(l2[-1] - l2[0])
	print(min(l3))
	n = n - 1


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	min1 = 1000
	for i in range(len(l) - 1, 0, -1):
		if min1 > l[i] - l[i - 1]:
			min1 = l[i] - l[i - 1]
	print(min1)


cases = int(input())
for t in range(cases):
	n = int(input())
	s = list(map(int, input().split()))
	s = sorted(s)
	minv = 1001
	for i in range(1, n):
		minv = min(minv, s[i] - s[i - 1])
	print(minv)


from sys import stdin

def r():
	return stdin.readline().strip()

def r_t(tp):
	return map(tp, r().strip().split())

def r_a(tp):
	return list(r_t(tp))

def main():
	cases = int(r())
	for case in range(cases):
		n = int(r())
		A = list(r_t(int))
		A.sort()
		ans = float('inf')
		for i in range(0, n - 1):
			ans = min(ans, A[i + 1] - A[i])
		print(ans)
main()


a = int(input())
for i in range(a):
	b = int(input())
	c = [int(j) for j in input().split(' ')[:b]]
	c.sort()
	r = 0
	r1 = 0
	if c[0] < c[1]:
		r1 = c[1] - c[0]
	else:
		r1 = c[0] - c[1]
	for k in range(1, len(c) - 1):
		if c[k] < c[k + 1]:
			r = c[k + 1] - c[k]
		else:
			r = c[k] - c[k + 1]
		if r < r1:
			r1 = r
	print(r1)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	a = sorted(a)
	d = 1001
	for i in range(1, n):
		if abs(a[i] - a[i - 1]) < d:
			d = abs(a[i] - a[i - 1])
		if d == 0:
			break
	print(d)


T = int(input())
for t in range(1, T + 1):
	N = int(input())
	lst = input().split()
	for i in range(N):
		lst[i] = int(lst[i])
	lst.sort()
	dif = lst[1] - lst[0]
	index = 0
	for i in range(N - 1):
		if lst[i + 1] - lst[i] < dif:
			dif = lst[i + 1] - lst[i]
			index = i
	print(dif)


for i in range(int(input())):
	r = []
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	for j in range(n - 1):
		r.append(l[j + 1] - l[j])
	print(min(r))


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	n = int(sys.stdin.readline())
	list_num = list(map(int, sys.stdin.readline().split()))
	list_num.sort()
	former = list_num[0]
	now_min = 10000
	for i in range(1, n):
		now_min = min(now_min, list_num[i] - former)
		former = list_num[i]
	print(now_min)


def solve():
	from sys import stdin, stdout
	t = int(stdin.readline())
	while t > 0:
		n = int(input())
		l = list(map(int, input().strip().split()))
		l.sort()
		m = 76775568347
		for i in range(n - 1):
			diff = l[i + 1] - l[i]
			if diff < m:
				m = diff
		print(m)
		t -= 1
solve()


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	minn = 10000
	for i in range(1, n):
		if s[i] - s[i - 1] < minn:
			minn = s[i] - s[i - 1]
	print(minn)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
for _ in range(ii()):
	n = ii()
	arr = sorted(li())
	min_ = 1000
	for i in range(n - 1):
		min_ = min(min_, arr[i + 1] - arr[i])
	print(min_)


t = int(input())
for i in range(t):
	N = int(input())
	abc = list(map(int, input().split()))
	abc.sort()
	min_delta = 100000000
	for j in range(N - 1):
		if abs(abc[j] - abc[j + 1]) < min_delta:
			min_delta = abs(abc[j] - abc[j + 1])
	print(min_delta)


no = int(input())
res = []
for i in range(no):
	a = int(input())
	x = list(map(int, input().split()))
	x = sorted(x)
	val = 99999
	for i in range(1, a):
		val = min(val, x[i] - x[i - 1])
	res.append(val)
for i in res:
	print(i)


for _ in range(int(input())):
	n = int(input())
	a = [] * n
	a = [int(i) for i in input().split()]
	a.sort()
	diff = int(a[1] - a[0])
	for i in range(0, n - 1):
		if a[i + 1] - a[i] < diff:
			diff = a[i + 1] - a[i]
	print(diff)


t = int(input())
while t:
	t -= 1
	n = int(input())
	p = input().split()
	s = list(map(int, p))
	s.sort()
	diff = 99999
	while n - 1 > 0:
		if s[n - 1] - s[n - 2] < diff:
			diff = s[n - 1] - s[n - 2]
		n -= 1
	print(diff)


t = int(input())
for T in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	d = []
	for i in range(n - 1):
		d.append(a[i + 1] - a[i])
	print(min(d))


import math
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(j) for j in input().split()]
	mn = max(a)
	for j in range(len(a)):
		for g in range(j + 1, len(a)):
			mn = min(mn, abs(a[j] - a[g]))
	print(mn)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = float('inf')
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < ans:
			ans = arr[i + 1] - arr[i]
	print(ans)


n1 = int(input())
for x in range(n1):
	n2 = int(input())
	l1 = input().split(' ')
	for y in range(n2):
		l1[y] = int(l1[y])
	l1.sort()
	mindif = 100000
	for y in range(0, n2 - 1):
		if l1[y + 1] - l1[y] <= mindif:
			mindif = l1[y + 1] - l1[y]
	print(mindif)


tc = int(input())
for ctr in range(tc):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	k = []
	for i in range(1, n):
		k.append(a[i] - a[i - 1])
	print(min(k))


for i in [0] * int(input()):
	a = int(input())
	l = sorted(list(map(int, input().split())))
	c = l[0] - l[1]
	for x in range(1, a - 1):
		z = l[x] - l[x + 1]
		c = max(c, z)
	print(-c)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	l = []
	for j in range(n - 1):
		l.append(abs(a[j] - a[j + 1]))
	print(min(l))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	diff = 0
	temp = []
	for i in range(len(l) - 1):
		temp.append(l[i + 1] - l[i])
	temp.sort()
	print(temp[0])


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	c = 0
	m = a[1] - a[0]
	for i in range(1, n - 1):
		k = a[i + 1] - a[i]
		if k < m:
			m = k
	print(m)


def fun(a, n):
	a.sort()
	c = a[n - 1]
	for i in range(n - 1):
		if abs(a[i] - a[i + 1]) < c:
			c = abs(a[i] - a[i + 1])
	print(c)
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	fun(a, n)


t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = l[-1]
	for i in range(1, n):
		k = abs(l[i] - l[i - 1])
		if m > k:
			m = k
	print(m)
	t -= 1


from collections import defaultdict as dd
import math
import sys
input = sys.stdin.readline

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))
q = nn()
for _ in range(q):
	n = nn()
	ex = lm()
	ex.sort()
	mindiff = 10000
	for i in range(n - 1):
		diff = ex[i + 1] - ex[i]
		mindiff = min(mindiff, diff)
	print(mindiff)


Answers = []
for i in range(int(input())):
	N = int(input())
	X = sorted(list(map(int, input().split())))
	Answers.append(str(min([X[i] - X[i - 1] for i in range(1, N)])))
print('\n'.join(Answers))


t = int(input())
for i in range(t):
	n = int(input())
	lists = list(map(int, input().split()))
	lists.sort()
	diff = lists[1] - lists[0]
	for j in range(1, n - 1):
		m = lists[j + 1] - lists[j]
		if m < diff:
			diff = m
	print(diff)


t = int(input())
for i in range(t):
	input()
	s = [int(r) for r in input().split()]
	s.sort()
	ans = max(s) - min(s)
	last = s[0]
	for z in range(1, len(s)):
		if s[z] - last < ans:
			ans = s[z] - last
		last = s[z]
	print(ans)


import sys
from collections import defaultdict as dd

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
import copy
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(x) for x in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def bo(i):
	return ord(i) - ord('a')
t = fi()
while t > 0:
	t -= 1
	n = fi()
	a = li()
	a.sort()
	mini = 10 ** 18
	for i in range(1, n):
		mini = min(mini, a[i] - a[i - 1])
	print(mini)


for _ in range(int(input())):
	n = int(input())
	s = sorted(map(int, input().split()))
	print(min((s[i] - s[i - 1] for i in range(1, n))))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	d = 1 << 10
	for i in range(1, n):
		if a[i] - a[i - 1] < d:
			d = a[i] - a[i - 1]
	print(d)


t = int(input())
s = ''
for i in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	c = li[1] - li[0]
	for i in range(2, len(li)):
		if li[i] - li[i - 1] < c:
			c = li[i] - li[i - 1]
	s += str(c) + ' '
print(s.replace(' ', '\n'))


t = int(input())
for i in range(t):
	n = int(input())
	players = list(map(int, input().split()))
	players.sort(reverse=True)
	min = players[0] - players[1]
	try:
		for ith in range(n):
			if players[ith] - players[ith + 1] < min:
				min = players[ith] - players[ith + 1]
	except:
		pass
	print(min)


t = int(input())
for item in range(t):
	a = int(input())
	lst = [int(i) for i in input().split()]
	lst.sort()
	lst1 = []
	for i in range(a - 1):
		lst1.append(lst[i + 1] - lst[i])
	print(min(lst1))


import math
t = int(input())
while t != 0:
	n = int(input())
	ar = list(map(int, input().strip().split()))
	mindiff = math.inf
	ar.sort()
	for i in range(1, len(ar)):
		if ar[i] - ar[i - 1] < mindiff:
			mindiff = ar[i] - ar[i - 1]
	print(mindiff)
	t -= 1


def func(n):
	for i in range(n):
		inp = int(input())
		k = list(map(int, input().split()))
		k.sort()
		minimum = 1000
		for i in range(len(k) - 1):
			if k[i + 1] - k[i] < minimum:
				minimum = k[i + 1] - k[i]
		print(minimum)
n = int(input())
func(n)


import sys
input = sys.stdin.readline
t = int(input())
for r in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	i = 0
	mini = 100000000000000
	while i < n - 1:
		mini = min(mini, abs(l[i] - l[i + 1]))
		i += 1
	print(mini)


cases = int(input(''))
output = []
for c in range(cases):
	list1 = []
	list2 = []
	size = int(input(''))
	x = input('').split()
	if size == 2:
		output.append(abs(int(x[0]) - int(x[1])))
		continue
	for i in range(size):
		list1.append(int(x[i]))
	list1.sort()
	for z in range(size - 1):
		list2.append(list1[z + 1] - list1[z])
	list2.sort()
	output.append(list2[0])
print(*output, sep='\n')


for i in [*open(0)][2::2]:
	i = sorted(list(map(int, i.split())))[::-1]
	g = i[0]
	for x in range(len(i) - 1):
		if g > i[x] - i[x + 1]:
			g = i[x] - i[x + 1]
	print(g)


t = int(input())
while t > 0:
	n = int(input())
	m = list(map(int, input().split()))
	m.sort()
	min = 100000
	for x in range(0, len(m) - 1):
		if m[x + 1] - m[x] < min:
			min = m[x + 1] - m[x]
	print(min)
	t -= 1


a = int(input())
for i in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	e = 9999999
	d = sorted(c)
	for i in range(1, b):
		if d[i] - d[i - 1] < e:
			e = d[i] - d[i - 1]
	print(e)


R = lambda : map(int, input().split())
for _ in range(int(input())):
	input()
	arr = sorted(R())
	(diff, pre) = (arr[1] - arr[0], arr[1])
	for i in arr[2:]:
		diff = min(diff, i - pre)
		pre = i
	print(diff)


import collections
t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	m = s[1] - s[0]
	for i in range(2, n):
		m = min(m, s[i] - s[i - 1])
	print(m)


t = int(input())
for x in range(t):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	arr.sort()
	min_dif = 10000
	for i in range(n - 1):
		min_dif = min(min_dif, arr[i + 1] - arr[i])
	print(min_dif)


for _ in range(int(input())):
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	prev = s[0]
	dif = 1001
	for i in range(1, n):
		diff = s[i] - prev
		prev = s[i]
		if diff < dif:
			dif = diff
	print(dif)


for _ in range(int(input())):
	n = int(input())
	strength = list(map(int, input().split()))
	strength.sort()
	mini = strength[-1] - strength[0]
	for i in range(n - 1):
		if strength[i + 1] - strength[i] < mini:
			mini = strength[i + 1] - strength[i]
	print(mini)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	arr2 = []
	for j in range(n - 1):
		arr2.append(abs(arr[j + 1] - arr[j]))
	print(min(arr2))


for _ in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	m = 10000
	for i in range(n - 1):
		x = l[i + 1] - l[i]
		m = min(m, x)
	print(m)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	res = abs(a[1] - a[0])
	for (i, x) in enumerate(a):
		for (j, y) in enumerate(a):
			if i == j:
				continue
			if res > abs(x - y):
				res = abs(x - y)
	print(res)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = float('inf')
	for (i, el1) in enumerate(arr):
		for (j, el2) in enumerate(arr[:i]):
			ans = min(ans, abs(el1 - el2))
	print(ans)


t = int(input())
for _ in range(0, t):
	n = int(input())
	a = []
	a = list(map(int, input().split()))
	a.sort()
	min1 = 100000000000000
	for i in range(0, n):
		for j in range(n - 1, 0, -1):
			d = a[j] - a[j - 1]
			if d < min1:
				min1 = d
	print(min1)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	hashmap = defaultdict(int)
	done = False
	for i in range(n):
		hashmap[arr[i]] += 1
		if hashmap[arr[i]] > 1:
			print(0)
			done = True
			break
	if done:
		continue
	for ans in range(1, 1000):
		for i in range(n):
			if arr[i] - ans > 0 and arr[i] - ans in hashmap:
				print(ans)
				done = True
				break
		if done:
			break


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	dif = 1001
	l.sort()
	flag = 0
	for i in range(1, n):
		if l[i] == l[i - 1]:
			flag = 1
			break
	if flag:
		print(0)
	else:
		for i in range(1, n):
			d = l[i] - l[i - 1]
			if d < dif:
				dif = d
		print(dif)


t = int(input())
for i in range(t):
	n = int(input())
	s = [int(a) for a in input().split()]
	s.sort()
	mn = 10 ** 10
	for i in range(n - 1):
		mn = min(mn, abs(s[i] - s[i + 1]))
	print(mn)


n = int(input())
for j in range(0, n):
	m = int(input())
	list = [*map(int, input().split(' '))]
	a = sorted(list)
	min = a[-1]
	for i in range(1, len(a)):
		if a[i] - a[i - 1] <= min:
			min = a[i] - a[i - 1]
	print(min)


iterations = int(input())
import math
for i in range(iterations):
	a = []
	b = []
	diff = []
	n = int(input())
	S = list(map(int, input().split()))
	S.sort()
	if n == 2:
		print(abs(S[0] - S[1]))
	else:
		for i in range(0, len(S) - 1):
			diff.append(abs(S[i] - S[i + 1]))
		print(min(diff))


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	mx = float('inf')
	for i in range(len(s) - 1):
		k = s[i + 1] - s[i]
		mx = min(k, mx)
		if mx == 0:
			break
	print(mx)


t = int(input())
for i in range(t):
	N = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	L = []
	for i in range(N - 1):
		B = abs(arr[i] - arr[i + 1])
		L.append(B)
	print(min(L))


t = int(input())
for i in range(t):
	n = int(input())
	S = list(map(int, input().split()))
	S.sort()
	ans = S[-1] - S[0]
	for j in range(n - 1):
		if S[j + 1] - S[j] < ans:
			ans = S[j + 1] - S[j]
		if ans == 0:
			break
	print(ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	players = [int(i) for i in input().split()]
	minn = 1100
	for i in range(len(players)):
		for j in range(i + 1, len(players)):
			if abs(players[i] - players[j]) < minn:
				minn = abs(players[i] - players[j])
	print(minn)


import sys
inp = [int(x) for x in sys.stdin.read().split()]
ii = 0
ttt = inp[ii]
ii += 1
res = []
for _ in range(ttt):
	n = inp[ii]
	ii += 1
	a = sorted(inp[ii:ii + n])
	ii += n
	c = 10000
	for i in range(n - 1):
		c = min(c, abs(a[i] - a[i + 1]))
	res.append(c)
print('\n'.join((str(x) for x in res)))


t = int(input())
for i in range(t):
	n = int(input())
	athlets = [int(x) for x in input().split()]
	athlets.sort()
	min_dif = athlets[1] - athlets[0]
	for i in range(2, len(athlets)):
		if athlets[i] - athlets[i - 1] < min_dif:
			min_dif = athlets[i] - athlets[i - 1]
	print(min_dif)


t = int(input())
for i in range(t):
	n = int(input())
	A = sorted(map(int, input().split()))
	d = abs(A[0] - A[1])
	for j in range(n - 1):
		d = min(d, abs(A[j] - A[j + 1]))
	print(d)


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for tt in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = float('inf')
	for i in range(1, n):
		ans = min(l[i] - l[i - 1], ans)
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	numb = sorted(list(map(int, input().split())))
	ans = numb[1] - numb[0]
	for i in range(len(numb) - 1):
		if numb[i + 1] - numb[i] < ans:
			ans = numb[i + 1] - numb[i]
		if ans == 0:
			break
	print(ans)


for i in range(int(input())):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	cur_min = s[-1] - s[0]
	for j in range(1, n):
		if s[j] - s[j - 1] < cur_min:
			cur_min = s[j] - s[j - 1]
	print(cur_min)


t = int(input())
for i in range(t):
	n = int(input())
	stren = [int(i) for i in input().split()]
	stren.sort()
	count = []
	for s in range(n - 1):
		count.append(stren[s + 1] - stren[s])
	print(min(count))


for i in range(0, int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	q = []
	for j in range(1, n):
		q.append(abs(a[j] - a[j - 1]))
	print(min(q))


for u in range(int(input())):
	n = int(input())
	y = [int(w) for w in input().split()]
	x = sorted(y)
	m = x[1] - x[0]
	for i in range(1, n - 1):
		if x[i + 1] - x[i] <= m:
			m = x[i + 1] - x[i]
	print(m)


import math
testcases = int(input())
for i in range(testcases):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = 9999999999999999999
	arr.sort()
	for i in range(n - 1):
		if abs(arr[i] - arr[i + 1]) < ans:
			ans = abs(arr[i] - arr[i + 1])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	p = [a[0] - a[-1]]
	for i in range(1, n):
		p.append(a[i - 1] - a[i])
	print(min(p))


import sys

def solve():
	return None

def main():
	q = []
	for line in sys.stdin.readlines():
		q.append(line)
	for i in range(len(q)):
		q[i] = q[i].rstrip().split(' ')
		q[i] = [int(x) for x in q[i]]
	for i in range(1, len(q), 2):
		a = q[i + 1]
		a.sort()
		d = 0
		m = 9999999
		for i in range(len(a) - 1):
			d = abs(a[i] - a[i + 1])
			if m > d:
				m = d
		print(m)
main()


def solve():
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	min = 100000000000
	for i in range(n - 1):
		if l[i + 1] - l[i] < min:
			min = l[i + 1] - l[i]
	return min
for _ in range(int(input())):
	print(solve())


xt = int(input())
for im in range(xt):
	k = []
	w = int(input())
	l = input().split()
	for u in range(len(l)):
		l[u] = int(l[u])
	l.sort(reverse=False)
	for r in range(1, len(l)):
		k.append(l[r] - l[r - 1])
	print(min(k))


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	a = max(x) - min(x)
	for i in range(n):
		for j in range(i + 1, n):
			if i != j and abs(x[i] - x[j]) < a:
				a = abs(x[i] - x[j])
	print(a)


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))[:N]
	A.sort()
	diff = []
	for i in range(0, N - 1):
		diff.append(A[i + 1] - A[i])
	print(min(diff))


cases = int(input())
for i in range(cases):
	number = int(input())
	alist = list(map(int, input().split()))
	alist.sort()
	newlist = []
	for p in range(len(alist) - 1):
		newlist.append(abs(alist[p] - alist[p + 1]))
	print(min(newlist))


t = int(input())
for _ in range(0, t):
	n = int(input())
	lis = list(map(int, input().split()))
	l = set(lis)
	lis.sort()
	if len(lis) != len(l):
		print(0)
	else:
		ans = 1000000000000
		for i in range(0, n - 1):
			temp = lis[i + 1] - lis[i]
			if abs(temp) < ans:
				ans = abs(temp)
		print(ans)


t = int(input())
for _ in range(0, t):
	n = int(input())
	a = [int(z) for z in input().split()]
	x = 100001
	a.sort()
	for i in range(0, len(a) - 1):
		x = min(x, abs(a[i + 1] - a[i]))
	print(x)


for _ in range(int(input())):
	n = int(input())
	a = sorted([int(i) for i in input().split()])
	mi = 10000
	for j in range(n - 1):
		mi = min(a[j + 1] - a[j], mi)
	print(mi)


t = int(input(''))
for i in range(t):
	n = int(input(''))
	s = input('')
	L = s.split(' ')
	B = []
	for i in range(len(L)):
		L[i] = int(L[i])
	L.sort()
	for j in range(len(L) - 1):
		B.append(L[j + 1] - L[j])
	print(min(B))


t = int(input())
for i in range(1, t + 1):
	a = int(input())
	athlets = map(int, input().split(' '))
	athletsort = sorted(athlets)
	min = 1000
	for x in range(len(athletsort) - 1):
		if athletsort[x + 1] - athletsort[x] < min:
			min = athletsort[x + 1] - athletsort[x]
	print(min)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mini = max(a)
	for i in range(n - 1):
		val = a[i + 1] - a[i]
		if val < mini:
			mini = val
	print(mini)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 1e+18
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


from collections import deque
from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	print(min([arr[i + 1] - arr[i] for i in range(n - 1)]))


test_cases = int(input())
for i in range(test_cases):
	number_of_students = int(input())
	athletes = sorted([int(i) for i in input().split()])
	list_a = []
	list_b = []
	shortest_distance = 1001
	for j in range(len(athletes) - 1):
		if athletes[j + 1] - athletes[j] < shortest_distance:
			shortest_distance = athletes[j + 1] - athletes[j]
	print(shortest_distance)


test = int(input())
for t in range(test):
	n = int(input())
	arr = input().split()
	arr.sort(key=int)
	diff = 1000000
	for i in range(n - 1):
		if int(arr[i + 1]) - int(arr[i]) < diff:
			diff = int(arr[i + 1]) - int(arr[i])
	print(diff)


for i in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	f = []
	for i in range(n - 1):
		f.append(abs(l[i] - l[i + 1]))
	print(min(f))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	max = l.count(l[0])
	for j in l:
		if max < l.count(j):
			max = j
	if max > 1:
		print(0)
		continue
	min = abs(l[1] - l[0])
	for j in range(len(l) - 1):
		if min > abs(l[j + 1] - l[j]):
			min = abs(l[j + 1] - l[j])
	print(min)


for T in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mn = 1000000000.0
	for i in range(n - 1):
		mn = min(mn, arr[i + 1] - arr[i])
	print(mn)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mini = l[1] - l[0]
	for i in range(n - 1):
		mini = min(mini, l[i + 1] - l[i])
	print(mini)


import sys
import heapq
import random
import collections

def solve(lst):
	lst = sorted(lst)
	return min([abs(a - b) for (a, b) in zip(lst[1:], lst[:-1])])

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	_ = int(input())
	lst = list(map(int, input().split()))
	res = solve(lst)
	print(res)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	m = 10 ** 5
	for i in range(n - 1):
		m = min(m, a[i + 1] - a[i])
		if m == 0:
			break
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	diff = 10000
	for i in range(1, n):
		diff = min(diff, li[i] - li[i - 1])
	print(diff)


t = int(input())
while t > 0:
	n = int(input())
	li = list(map(int, input().split(' ')))
	li.sort()
	cur = li[0]
	res = 100000
	if len(li) == 2:
		print(abs(li[0] - li[1]))
	else:
		for i in li[1:]:
			if abs(i - cur) < res:
				res = abs(i - cur)
			cur = i
		print(res)
	t -= 1


for __ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 2 ** 31
	for i in range(n - 1):
		ans = min(arr[i + 1] - arr[i], ans)
	print(ans)


numberofcases = int(input())
for _ in range(numberofcases):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	print(min([l[i + 1] - l[i] for i in range(n - 1)]))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	if len(s) != n:
		print('0')
	else:
		l.sort()
		m = l[1] - l[0]
		for i in range(n - 1):
			if l[i + 1] - l[i] < m:
				m = l[i + 1] - l[i]
		print(m)


for _ in range(int(input())):
	input()
	l = sorted(map(int, input().split()))
	print(min([l[i] - l[i - 1] for i in range(1, len(l))]))


from sys import stdin, stdout
for i in range(int(stdin.readline())):
	stdin.readline()
	aths = [int(i) for i in stdin.readline().split()]
	aths.sort()
	min_diff = 1001
	for index in range(len(aths) - 1):
		diff = abs(aths[index] - aths[index + 1])
		if diff < min_diff:
			min_diff = diff
	print(min_diff)


t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	li.sort()
	lfi = []
	for i in range(n - 1):
		lfi.append(li[i + 1] - li[i])
	print(min(lfi))


def main(s):
	s = list(map(int, s.split(' ')))
	s.sort()
	m = s[-1]
	for i in range(1, len(s)):
		m = min(m, abs(s[i] - s[i - 1]))
	return m
n = int(input())
for i in range(n):
	x = input()
	x = input()
	print(main(x))


t = int(input())
for i in range(t):
	size = int(input())
	arr = sorted(list(map(int, input().split())))
	diff = []
	for i in range(len(arr) - 1):
		diff.append(arr[i + 1] - arr[i])
	print(min(diff))


import math
Test = int(input())
while Test > 0:
	n = int(input())
	a = list(map(int, input().split()))
	a.insert(0, -1)
	a.sort()
	ans = math.inf
	for i in range(1, n):
		ans = min(ans, a[i + 1] - a[i])
	print(ans)
	Test -= 1


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = 10000000
	for i in range(1, n):
		m = min(m, l[i] - l[i - 1])
	print(m)


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	print(min((abs(s[i] - s[i + 1]) for i in range(n - 1))))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	diff = 10000
	for i in range(n - 1, 0, -1):
		if a[i] - a[i - 1] < diff:
			diff = a[i] - a[i - 1]
	print(diff)


import sys

def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = abs(a[0] - a[-1])
	for i in range(1, len(a)):
		ans = min(ans, abs(a[i] - a[i - 1]))
	print(ans)
input = sys.stdin.readline
tn = int(input())
for _ in range(tn):
	main()


import sys
import math
t = int(sys.stdin.readline().strip())
for i in range(t):
	n = int(sys.stdin.readline().strip())
	l = sorted(list(map(int, sys.stdin.readline().strip().split(' '))))
	minDiff = math.inf
	for i in range(1, len(l)):
		minDiff = min(minDiff, abs(l[i] - l[i - 1]))
	print(minDiff)


def partition(arr, low, high):
	i = low - 1
	pivot = arr[high]
	for j in range(low, high):
		if arr[j] <= pivot:
			i = i + 1
			(arr[i], arr[j]) = (arr[j], arr[i])
	(arr[i + 1], arr[high]) = (arr[high], arr[i + 1])
	return i + 1

def quickSort(arr, low, high):
	if low < high:
		pi = partition(arr, low, high)
		quickSort(arr, low, pi - 1)
		quickSort(arr, pi + 1, high)
t = int(input())
for jh in range(t):
	n = int(input())
	o = 1001
	a = input()
	arr = a.split(' ')
	for i in range(0, n):
		arr[i] = int(arr[i])
	quickSort(arr, 0, n - 1)
	for i in range(0, n - 1):
		k = arr[i + 1] - arr[i]
		if o > k:
			o = k
	print(o)
print('\n')


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mini = abs(a[0] - a[1])
	for i in range(1, n):
		mini = min(mini, abs(a[i] - a[i - 1]))
	print(mini)


for i in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	k = []
	for i in range(len(l) - 1):
		k.append(l[i + 1] - l[i])
	print(min(k))


test_case = int(input())
while test_case:
	n = int(input())
	s = sorted(map(int, input().split()))
	print(min([abs(a - b) for (a, b) in zip(s, s[1:])]))
	test_case -= 1


for case in range(int(input())):
	N = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	answer = 9876543210
	for n in range(N - 1):
		answer = min(answer, arr[n + 1] - arr[n])
	print(answer)


def main():
	t = int(input())
	for _ in range(t):
		_ = input()
		a = [int(x) for x in input().split()]
		a.sort()
		min_d = a[-1]
		for i in range(len(a) - 1):
			min_d = min(min_d, a[i + 1] - a[i])
		print(min_d)
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(k) for k in input().split()]
	val = 10000000000.0
	cur = 10000000000.0
	a.sort()
	for x in range(len(a)):
		for y in range(x, len(a) - 1):
			cur = a[y + 1] - a[x]
			val = min(val, cur)
	print(val)


t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted([int(ipt) for ipt in input().split()])
	ret = s[1] - s[0]
	for i in range(1, n):
		ret = min(s[i] - s[i - 1], ret)
	print(ret)


T = int(input())
for _ in range(T):
	N = int(input())
	arr = [int(i) for i in input().split()]
	arr = sorted(arr)
	mini = abs(arr[1] - arr[0])
	for i in range(1, len(arr) - 1):
		if abs(arr[i] - arr[i + 1]) < mini:
			mini = abs(arr[i] - arr[i + 1])
	print(mini)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = 100000
	for j in range(n - 1, 0, -1):
		if l[j] - l[j - 1] < m:
			m = l[j] - l[j - 1]
			a = j
	print(l[a] - l[a - 1])


testCases = int(input())

def same(l):
	diff = 9999999
	for i in range(len(l) - 1):
		if l[i] == l[i + 1]:
			return -1
		elif abs(l[i + 1] - l[i]) < diff:
			diff = abs(l[i + 1] - l[i])
	return diff
for i in range(testCases):
	totalAtheletes = int(input())
	strengths = list(map(int, input().split(' ')))
	strengths.sort()
	res = same(strengths)
	if res == -1:
		print(0)
	else:
		print(res)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	res = max(s)
	for j in range(n - 1):
		res = min(res, s[j + 1] - s[j])
	print(res)


import os
import sys
from io import BytesIO, IOBase

def solution(arr, n):
	arr.sort()
	res = float('inf')
	for i in range(1, n):
		res = min(res, arr[i] - arr[i - 1])
	write(res)

def main():
	for _ in range(r_int()):
		n = r_int()
		arr = r_array()
		solution(arr, n)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	pee = []
	for i in range(1, n):
		pee.append(s[i] - s[i - 1])
	print(min(pee))


t = int(input())
for i in range(t):
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	output = s[-1]
	for j in range(n - 1):
		output = min(output, s[j + 1] - s[j])
	print(output)


for _ in range(int(input())):
	(a, l) = (int(input()), sorted(list(map(int, input().split()))))
	print(min((l[x] - l[x - 1] for x in range(1, a))))


inp = int(input())
for x in range(0, inp):
	inp1 = input()
	inp2 = input().split()
	smallest = 1000
	executed = False
	for num in range(0, len(inp2)):
		for x in range(num + 1, len(inp2)):
			if int(inp2[x]) == int(inp2[num]):
				print(0)
				executed = True
				break
			elif abs(int(inp2[num]) - int(inp2[x])) < smallest:
				smallest = abs(int(inp2[num]) - int(inp2[x]))
		if executed == True:
			break
	else:
		print(smallest)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	c = 1001
	for i in range(1, n):
		c = min(c, abs(l[i] - l[i - 1]))
	print(c)


for something in range(int(input())):
	n = int(input())
	a = sorted((int(x) for x in input().split()))
	print(min((a[i] - a[i - 1] for i in range(1, n))))


def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split(' ')))
t = read_int()
for case_num in range(t):
	n = read_int()
	a = list(read_ints())
	a.sort()
	ans = int(1000000000.0)
	for i in range(n - 1):
		ans = min(ans, abs(a[i] - a[i + 1]))
	print(ans)


t = int(input())
for z in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	min = arr[1] - arr[0]
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < min:
			min = arr[i + 1] - arr[i]
	print(min)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	d = []
	for x in range(1, n):
		d.append(abs(a[x] - a[x - 1]))
	print(min(d))
t = int(input())
for x in range(t):
	solve()


n = int(input())
for i in range(n):
	f = 0
	k = int(input())
	l = list(map(int, input().split()))
	l.sort()
	for p in range(k - 1):
		if l[p] == l[p + 1]:
			f = 1
			print('0')
			break
	m = abs(l[0] - l[1])
	if f != 1:
		for q in range(k - 1):
			if abs(l[q] - l[q + 1]) < m:
				m = abs(l[q] - l[q + 1])
		print(m)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	rec = 9999999
	for j1 in range(n):
		for j2 in range(n):
			if j1 != j2:
				if abs(a[j1] - a[j2]) < rec:
					rec = abs(a[j1] - a[j2])
	print(rec)


for s in [*open(0)][2::2]:
	a = sorted(list(map(int, s.split())))
	print(min([j - i for (i, j) in zip(a, a[1:])]))


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	min_dif = max(li)
	li.sort()
	for i in range(len(li) - 1):
		if li[i + 1] - li[i] < min_dif:
			min_dif = li[i + 1] - li[i]
	print(min_dif)


from __future__ import division, print_function
import itertools
import sys
import os
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def is_it_local():
	script_dir = str(os.getcwd()).split('/')
	username = 'dipta007'
	return username in script_dir

def READ(fileName):
	if is_it_local():
		sys.stdin = open(f'./{fileName}', 'r')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if not is_it_local():
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')

def input1(type=int):
	return type(input())

def input2(type=int):
	[a, b] = list(map(type, input().split()))
	return (a, b)

def input3(type=int):
	[a, b, c] = list(map(type, input().split()))
	return (a, b, c)

def input_array(type=int):
	return list(map(type, input().split()))

def input_string():
	s = input()
	return list(s)

def main():
	t = input1()
	for ci in range(t):
		n = input1()
		arr = input_array()
		arr.sort()
		mn = 99999
		for i in range(1, len(arr)):
			mn = min(mn, arr[i] - arr[i - 1])
		print(mn)
	pass
READ('in.txt')
main()


import sys
cases = int(sys.stdin.readline())
for _ in range(cases):
	n = int(sys.stdin.readline())
	A = list(map(int, sys.stdin.readline().split()))
	A = sorted(A)
	min_diff = float('inf')
	for i in range(len(A) - 1):
		min_diff = min(min_diff, abs(A[i + 1] - A[i]))
	print(min_diff)


import math
for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	mi = 999999999
	for i in range(n - 1):
		mi = min(mi, li[i + 1] - li[i])
	print(mi)


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	ans = min((a[i] - a[i - 1] for i in range(1, n)))
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	mm = l[1] - l[0]
	for i in range(1, n - 1):
		if mm > l[i + 1] - l[i]:
			mm = l[i + 1] - l[i]
			if mm == 0:
				break
	print(mm)


t = int(input())
while t > 0:
	n = int(input())
	nums = list(map(int, input().split()))
	nums.sort()
	mind = None
	i = 1
	while i < len(nums):
		diff = abs(nums[i] - nums[i - 1])
		if mind == None or diff < mind:
			mind = diff
		i = i + 1
	print(mind)
	t = t - 1


t = int(input())
output = []
for i in range(t):
	n = int(input())
	list1 = input().split()
	for j in range(n):
		list1[j] = int(list1[j])
	list1.sort()
	mindiffer = list1[n - 1] - list1[0]
	for k in range(n - 1):
		mindiffer = min(mindiffer, abs(list1[k + 1] - list1[k]))
	output.append(mindiffer)
for items in output:
	print(items)


def main():
	for __ in [0] * int(input()):
		N = int(input())
		(*S,) = map(int, input().split())
		S.sort()
		mindiff = 10 ** 10
		prev = S[0]
		for s in S[1:]:
			mindiff = min(mindiff, s - prev)
			prev = s
		print(mindiff)
main()


test_cases = int(input())
for z in range(test_cases):
	n = int(input())
	athlete = list(map(int, input().split()))
	athlete.sort()
	diff = 100001
	for i in range(len(athlete) - 1):
		if diff > athlete[i + 1] - athlete[i]:
			diff = athlete[i + 1] - athlete[i]
	print(diff)


try:
	for _ in range(int(input())):
		n = int(input())
		s = list(map(int, input().split()))
		s.sort()
		print(min((abs(s[i] - s[i + 1]) for i in range(n - 1))))
except:
	pass


from collections import defaultdict

def func(A):
	A.sort()
	res = 10000000
	for i in range(len(A) - 1):
		res = min(res, A[i + 1] - A[i])
	return res
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	print(func(A))


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = 99999999999999999999999
	for i in range(1, n):
		ans = min(ans, s[i] - s[i - 1])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	lst = []
	for i in range(n - 1):
		lst.append(arr[i + 1] - arr[i])
	print(min(lst))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = 1000
	for i in range(len(l)):
		for j in range(len(l)):
			if abs(l[i] - l[j]) < d and j != i:
				d = abs(l[i] - l[j])
	print(d)


t = int(input())
cases = [[int(input()), sorted(list(map(int, input().split())))] for _ in range(t)]
for case in cases:
	n = case[0]
	arr = case[1]
	AB = None
	for i in range(n - 1):
		if AB != None:
			AB = min(AB, arr[i + 1] - arr[i])
		else:
			AB = arr[i + 1] - arr[i]
	print(AB)


t = int(input())
for test in range(t):
	n = int(input())
	lst = [int(i) for i in input().split()][:n]
	lst.sort()
	min = lst[1] - lst[0]
	for i in range(1, n - 1):
		if lst[i + 1] - lst[i] < min:
			min = lst[i + 1] - lst[i]
	print(min)


t = int(input())
for tt in range(t):
	n = int(input())
	v = list(map(int, input().split()))
	v.sort()
	res = 1000000
	for i in range(1, len(v)):
		res = min(res, abs(v[i] - v[i - 1]))
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	min = 999
	for i in range(1, n):
		if lst[i] - lst[i - 1] < min:
			min = lst[i] - lst[i - 1]
	print(min)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	min = 1000
	for i in range(n - 1):
		d = l[i + 1] - l[i]
		if d < min:
			min = d
	print(min)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().rstrip().split()))
	s.sort()
	res = s[1] - s[0]
	for x in range(n - 1):
		if s[x + 1] - s[x] < res:
			res = s[x + 1] - s[x]
	print(res)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = 10 ** 9
	for i in range(n - 1):
		if s[i + 1] - s[i] < ans:
			ans = s[i + 1] - s[i]
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	if len(set(a)) < len(a):
		print(0)
	else:
		mi = 10000000
		for i in range(n):
			for j in range(i + 1, n):
				if abs(a[i] - a[j]) < mi:
					mi = abs(a[i] - a[j])
		print(mi)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	d = 20000
	for i in range(1, n):
		d = min(d, abs(s[i] - s[i - 1]))
	print(d)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = float('infinity')
	for i in range(n - 1):
		m = min(m, l[i + 1] - l[i])
	print(m)


for _ in range(int(input())):
	n = int(input())
	li = [int(i) for i in input().split()]
	li.sort()
	dp = [0 for i in range(n)]
	for i in range(1, n):
		dp[i] = li[i] - li[i - 1]
	dp.pop(0)
	print(min(dp))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list([int(x) for x in input().split()])
	l.sort()
	arr = []
	for i in range(1, n):
		arr.append(l[i] - l[i - 1])
	arr.sort()
	print(arr[0])


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	mini = float('inf')
	for i in range(1, n):
		if a[i] - a[i - 1] < mini:
			mini = a[i] - a[i - 1]
	print(mini)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mini = 199999999999
	for i in range(1, n):
		if mini != 0:
			if abs(l[i] - l[i - 1]) <= mini:
				mini = abs(l[i] - l[i - 1])
		else:
			break
	print(mini)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = 2e+18
	l.sort()
	for t in range(1, n):
		ans = min(ans, abs(l[t] - l[t - 1]))
	print(ans)


import sys
import math
from sys import stdin, stdout

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def main():
	for t in range(int(input())):
		n = int(input())
		a = [int(x) for x in input().split()]
		a.sort()
		c = 99999999
		for i in range(n - 1):
			c = min(c, a[i + 1] - a[i])
		print(c)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	array = sorted(list(map(int, input().split())))
	low = array[-1] - array[0]
	for i in range(n):
		if abs(array[i] - array[i - 1]) < low:
			low = abs(array[i] - array[i - 1])
	print(low)


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	A = sorted(A)
	min = 1000
	for i in range(1, N):
		val = abs(A[i] - A[i - 1])
		if val < min:
			min = val
	print(min)


import sys
input = sys.stdin.readline
t = int(input())
for q in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	m = a[0] - a[1]
	c = 0
	for x in range(n - 1):
		c = a[x] - a[x + 1]
		if c < m:
			m = c
	print(m)


for _ in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	b.sort()
	mi = b[n - 1] - b[0]
	for i in range(n - 1):
		mi = min(mi, b[i + 1] - b[i])
	print(mi)


inp = lambda : map(int, input().split())
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(inp())
	d = []
	l = sorted(l)
	for i in range(1, len(l)):
		d.append(abs(l[i - 1] - l[i]))
	print(min(d))


start_number = int(input())
quantity_min_value = []
power_number_integer = []
while start_number != 0:
	first_number = int(input())
	power_number_integer = map(int, input().split())
	power_number_integer = list(power_number_integer)
	power_number_integer.sort()
	min_value = power_number_integer[1] - power_number_integer[0]
	for i in range(0, len(power_number_integer) - 1):
		if power_number_integer[i + 1] - power_number_integer[i] < min_value:
			min_value = power_number_integer[i + 1] - power_number_integer[i]
	quantity_min_value.append(min_value)
	start_number -= 1
for i in quantity_min_value:
	print(i)


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	ans = []
	for _ in range(n):
		x = I()
		l = LI()
		mn = inf
		for i in range(x):
			for j in range(x):
				if i == j:
					continue
				mn = min(mn, abs(l[i] - l[j]))
		ans.append(mn)
	for x in ans:
		print(x)
main()


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
entries = inp()
for i in range(entries):
	n = inp()
	l = inlt()
	l.sort()
	res = 10000
	for i in range(len(l) - 1):
		if l[i + 1] - l[i] < res:
			res = l[i + 1] - l[i]
	print(res)


for tc in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 10001
	for i in range(1, n):
		ans = min(ans, l[i] - l[i - 1])
	print(ans)


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
for _ in range(ii()):
	n = ii()
	a = il()
	a.sort()
	b = []
	for i in range(0, n - 1):
		b.append(abs(a[i] - a[i + 1]))
	b.append(abs(a[n - 1] - a[n - 2]))
	print(min(b))


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mi = 9999999
	for i in range(len(a) - 1):
		mi = min(mi, a[i + 1] - a[i])
	print(mi)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(v) for v in input().split()]
	a.sort()
	m = 20000
	for j in range(n - 1):
		m = min(m, a[j + 1] - a[j])
	print(m)


ans = []
for i in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	diff = []
	for j in range(1, n):
		diff.append(arr[j] - arr[j - 1])
	ans.append(min(diff))
for it in ans:
	print(it)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	minn = -1
	for i in range(1, n):
		if minn == -1 or l[i] - l[i - 1] < minn:
			minn = l[i] - l[i - 1]
	print(minn)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	a.sort(reverse=True)
	m = abs(a[1] - a[0])
	for i in range(n - 1):
		if abs(a[i] - a[i + 1]) < m:
			m = abs(a[i] - a[i + 1])
	print(m)


cnt = 1
p = 0
r = []

def init(a):
	for p in range(len(a)):
		a[p] = int(a[p])
	return a
t = int(input())
for i in range(t):
	f = []
	n = int(input())
	d = input().split()
	d = init(d)
	d = sorted(d, reverse=True)
	for j in range(n - 1):
		f.append(abs(d[j] - d[j + 1]))
	r.append(int(min(f)))
for k in range(t):
	print(r[k])


def main():
	n = int(input())
	force = list(map(int, input().split()))
	force.sort()
	m = 10000
	for j in range(1, n):
		m = min(m, abs(force[j - 1] - force[j]))
	print(m)
t = int(input())
for i in range(t):
	main()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	minn = 10 ** 9
	for i in range(n - 1):
		if abs(arr[i] - arr[i + 1]) <= minn:
			minn = abs(arr[i] - arr[i + 1])
	print(minn)


from collections import *
from sys import *
inp = stdin.readline
f = 0
if f & 1:
	out = stdout.write
	str = str
else:
	out = print

def linp(x):
	return list(map(int, x.split()))

def minp(x):
	return map(int, x.split())
t = int(inp())
while t > 0:
	n = int(inp())
	s = linp(inp())
	s.sort()
	min1 = float('INF')
	for i in range(1, n):
		min1 = min(min1, s[i] - s[i - 1])
	print(min1)
	t -= 1


for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	res = 1000000005
	for i in range(n - 1):
		res = min(res, abs(a[i] - a[i + 1]))
	print(res)


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = arr[-1] - arr[-2]
	for i in range(n - 2, -1, -1):
		ans = min(ans, arr[i + 1] - arr[i])
	return ans

def main():
	t = int(input())
	while t:
		print(solve())
		t -= 1
main()


for i in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	a = []
	b = []
	c = []
	l.sort()
	while len(l) > 1:
		p = l[0]
		l.remove(l[0])
		a.append(p)
		la = max(a)
		b = l
		lb = min(b)
		c.append(lb - la)
	print(min(c))


def inp():
	return map(int, input().split())

def solve():
	n = int(input())
	a = list(inp())
	a.sort()
	m = 10000
	for i in range(1, n):
		d = a[i] - a[i - 1]
		if d < m:
			m = d
	print(m)

def main():
	t = int(input())
	while t:
		solve()
		t -= 1
main()


def fun(a, n):
	minn = 110000
	for i in range(n - 1):
		for j in range(i + 1, n):
			minn = min(minn, abs(a[j] - a[i]))
	return minn
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = fun(a, n)
	print(ans)


for case in range(int(input())):
	n = input()
	ath = sorted(list(map(int, input().split())))
	diff = 2000
	for i in range(int(n) - 1):
		if diff == 0:
			break
		if ath[i + 1] - ath[i] < diff:
			diff = ath[i + 1] - ath[i]
	print(diff)


t = int(input())

def solve(n, arr):
	arr.sort()
	best = float('inf')
	for i in range(1, len(arr)):
		best = min(best, arr[i] - arr[i - 1])
	return best
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(n, arr))


n = int(input())
for i in range(n):
	a = int(input())
	l = list(map(int, input().split()))
	k = sorted(l)
	m = []
	for i in range(0, len(k) - 1):
		dif = k[i + 1] - k[i]
		m.append(dif)
	j = sorted(m)
	print(j[0])


t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	l.sort()
	for i in range(0, len(l) - 1):
		d = abs(l[i] - l[i + 1])
		l1.append(d)
	m = min(l1)
	print(m)
	t -= 1


import sys
try:
	sys.stdin = open('Input.txt', 'r')
	sys.stdout = open('Output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for testCases in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = float('inf')
	for i in range(1, len(l)):
		d = min(d, l[i] - l[i - 1])
	print(d)


t = int(input())
for i in range(t):
	l = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	diff = 10 ** 5
	for i in range(len(lst) - 1):
		if diff > lst[i + 1] - lst[i]:
			diff = lst[i + 1] - lst[i]
	print(diff)


t = int(input(''))
for i in range(t):
	n = int(input(''))
	s = list(map(int, input().split(' ')))
	s.sort()
	dif = range(n - 1)
	dif = list(dif)
	for i in range(n - 1):
		dif[i] = s[i + 1] - s[i]
	print(min(dif))


a = input()
n_inputs = int(a)
entries = []
for i in range(n_inputs):
	n = input()
	data = input()
	sdata = data.split()
	entries.append(sdata)

def min_diff(n, sdata):
	diffs = []
	for i in range(n - 1):
		for j in range(i + 1, n):
			diffs.append(abs(int(sdata[i]) - int(sdata[j])))
	print(min(diffs))
for e in entries:
	min_diff(len(e), e)


t = int(input())
for i in range(t):
	input()
	s = sorted(list(map(int, input().split())))
	result = s[-1]
	for (idx, val) in enumerate(s[:-1]):
		result = min(result, s[idx + 1] - val)
	print(result)


n = int(input(''))
matrix = []
for i in range(n):
	x = input('')
	matrix.append(list(map(int, input().split())))
for i in range(n):
	k = matrix[i]
	k = sorted(k)
	dist = k[1] - k[0]
	for j in range(1, len(k) - 1, 1):
		dist = min(dist, k[j + 1] - k[j])
	print(dist)


for i in range(int(input())):
	x = int(input())
	l = sorted(list(map(int, input().split())), reverse=True)
	ans = l[0] - l[1]
	for i in range(0, len(l) - 1):
		if l[i] - l[i + 1] < ans:
			ans = l[i] - l[i + 1]
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	min = 100000
	for j in range(n):
		for k in range(j + 1, n):
			if abs(l[k] - l[j]) < min:
				min = abs(l[k] - l[j])
	print(min)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	_ = input()
	a = list(map(int, input().split()))
	a.sort()
	ans = 10000000000
	for (i, j) in zip(a, a[1:]):
		ans = min(ans, j - i)
	print(ans)


t = int(input())
for T in range(t):
	min_a = None
	n = int(input())
	Athlets = sorted(list(map(int, input().split())))
	for i in range(n):
		for j in range(n):
			if i > j:
				if min_a is None or abs(Athlets[i] - Athlets[j]) < min_a:
					min_a = abs(Athlets[i] - Athlets[j])
	print(min_a)


for t in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	e = 99999999
	for i in range(1, len(l)):
		e = min(e, l[i] - l[i - 1])
	print(e)


def main():
	n = int(input())
	lst = sorted(list(map(int, input().split())))
	dif = 9999999
	place = 0
	for i in range(0, n - 1):
		if lst[i + 1] - lst[i] < dif:
			dif = lst[i + 1] - lst[i]
			place = i
	print(dif)
t = int(input())
for i in range(t):
	main()


T = int(input())
for _ in range(T):
	n = int(input())
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	a.sort()
	m = 1001
	for i in range(n - 1):
		if a[i + 1] - a[i] < m:
			m = a[i + 1] - a[i]
	print(m)


t = int(input())
rez = []
for i in range(t):
	n = int(input())
	s = input().split(' ')
	for j in range(n):
		s[j] = int(s[j])
	s.sort()
	rezu = s[1] - s[0]
	for j in range(n - 1):
		if s[j + 1] - s[j] < rezu:
			rezu = s[j + 1] - s[j]
	rez.append(rezu)
for i in range(len(rez)):
	print(rez[i])


num = int(input())
final = [0] * num
for i in range(num):
	a = int(input())
	arr = [0] * a
	arr = input().split()
	for k in range(a):
		arr[k] = int(arr[k])
	arr.sort()
	mini = 100000000000000
	for y in range(a - 1):
		if arr[y + 1] - arr[y] < mini:
			mini = arr[y + 1] - arr[y]
	final[i] = mini
for p in range(num):
	print(final[p])


def main():
	n = int(input())
	for i in range(n):
		t = int(input())
		peo = str(input()).split(' ')
		for j in range(t):
			peo[j] = int(peo[j])
		peo.sort()
		diff = 1001
		for j in range(t - 1):
			temp = peo[j + 1] - peo[j]
			if temp < diff:
				diff = temp
		print(diff)
main()


n = int(input())
for i in range(n):
	m = int(input())
	a = [int(i) for i in input().split()]
	b = sorted(a)
	max = 10 ** 9
	for j in range(0, len(b) - 1):
		d = b[j + 1] - b[j]
		if d < max:
			max = d
	print(max)


for t in range(int(input())):
	n = int(input())
	a = sorted([int(i) for i in input().split()])
	min_diff = a[1] - a[0]
	for i in range(1, n):
		diff = a[i] - a[i - 1]
		if diff < min_diff:
			min_diff = diff
		if min_diff == 0:
			break
	print(min_diff)


def teams(values):
	values.sort()
	minimum = float('inf')
	for i in range(len(values) - 1):
		minimum = min(minimum, abs(values[i] - values[i + 1]))
	return minimum
t = int(input())
for i in range(t):
	n = int(input())
	values = list(map(int, input().split()))
	print(teams(values))


n = int(input())
for i in range(n):
	f = 0
	t = int(input())
	k = list(map(int, input().split()))
	k.sort()
	for j in range(t - 1):
		if k[j] == k[j + 1]:
			f = 1
			print('0')
			break
	s = abs(k[0] - k[1])
	if f != 1:
		for g in range(t - 1):
			if abs(k[g] - k[g + 1]) < s:
				s = abs(k[g] - k[g + 1])
		print(s)


def check(a):
	a = sorted(a)
	b = []
	for i in range(len(a) - 1):
		b.append(abs(a[i] - a[i + 1]))
	return min(b)
t = int(input())
for i in range(t):
	n = int(input())
	s = [int(x) for x in input().split()]
	print(check(s))


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	anew = sorted(arr)
	mi = 100000
	for x in range(len(anew) - 1):
		mi = min(mi, anew[x + 1] - anew[x])
	print(mi)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	i = 1
	m = 1000
	best = 1000
	while i < n:
		if l[i - 1] == l[i]:
			print(0)
			break
		else:
			diff = l[i] - l[i - 1]
			m = min(m, diff)
			best = min(m, best)
		i += 1
	if i == n:
		print(best)


t = int(input())
result = []
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	a.sort()
	mmin = a[1] - a[0]
	for i in range(1, len(a) - 1):
		if mmin > a[i + 1] - a[i]:
			mmin = a[i + 1] - a[i]
	result.append(mmin)
for i in result:
	print(i)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = 1001
	for i in range(n - 1):
		d = l[i + 1] - l[i]
		if d < m:
			m = d
	print(m)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	min_diference = 100000
	s.sort()
	for i in range(n - 1):
		min_diference = min(min_diference, s[i + 1] - s[i])
	print(min_diference)


T = int(input())
for t in range(T):
	N = int(input())
	S = sorted(map(int, input().split()))
	min_diff = S[1] - S[0]
	prev = S[1]
	for s in S[2:]:
		if s - prev < min_diff:
			min_diff = s - prev
		prev = s
	print(min_diff)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s1 = list(map(int, input().split()))
	s = sorted(s1, reverse=True)
	mans = 10 ** 9
	for i in range(1, n):
		x = abs(s[i] - s[i - 1])
		mans = min(x, mans)
	print(mans)


def solve():
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort()
	diff = 1000
	for i in range(n - 1):
		diff = min(diff, arr[i + 1] - arr[i])
	return diff
for _ in range(int(input())):
	print(solve())


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 1001
	for i in range(n - 1):
		ans = min(ans, a[i + 1] - a[i])
	print(ans)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def solve():
	n = int(inp())
	a = lis()
	a.sort()
	m = 99999999999999999
	for i in range(1, n):
		m = min(m, a[i] - a[i - 1])
	print(m)
testcase(int(inp()))


for i in range(int(input())):
	x = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	mn = 100000000
	for j in range(1, x):
		mn = min(mn, abs(ar[j - 1] - ar[j]))
	print(mn)


t = int(input())
while t > 0:
	t = t - 1
	b = int(input())
	a = [int(y) for y in input().split()]
	a.sort()
	count = a[1] - a[0]
	best = count
	for i in range(1, b - 1):
		count = a[i + 1] - a[i]
		best = min(best, count)
	print(best)


t = int(input())
for i in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	b = []
	for i in range(n - 1):
		b.append(a[i + 1] - a[i])
	print(min(b))


for _ in range(int(input())):
	n = int(input())
	li = sorted(list(map(int, input().split())))
	ans = li[-1] - li[0]
	for i in range(n):
		for j in range(i + 1, n):
			ans = min(ans, li[j] - li[i])
	print(ans)


for i in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	ans = 10000000
	for j in range(1, n):
		ans = min(ans, lst[j] - lst[j - 1])
	print(ans)


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	a = get_array()
	a.sort()
	c = []
	for i in range(len(a) - 1):
		c.append(a[i + 1] - a[i])
	print(min(c))


for testcase in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mini = float('inf')
	for i in range(1, len(arr)):
		mini = min(mini, arr[i] - arr[i - 1])
	print(mini)


t = int(input())
ans = []
for g in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	mn = s[-1]
	for i in range(1, n):
		if s[i] - s[i - 1] < mn:
			mn = s[i] - s[i - 1]
	ans += [mn]
for i in ans:
	print(i)


import sys
for i in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	l = [int(x) for x in sys.stdin.readline().split()]
	l.sort()
	mini = 10000000000
	for i in range(n - 1):
		mini = min(l[i + 1] - l[i], mini)
	print(mini)


for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	minn = 10 ** 100
	for i in range(n - 1):
		minn = min(minn, arr[i + 1] - arr[i])
	print(minn)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	res = 9999
	for i in range(1, len(l)):
		res = min(l[i] - l[i - 1], res)
	print(res)


import sys
input = sys.stdin.readline
tc = int(input())
for _ in range(tc):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	checker = sys.maxsize
	for i in range(n - 1):
		if abs(s[i] - s[i + 1]) < checker:
			checker = abs(s[i] - s[i + 1])
	print(checker)


t = int(input())
for i in range(t):
	n = int(input())
	listt = list(map(int, input().split()))
	listt.sort()
	listm = []
	for i in range(len(listt) - 1):
		listm.append(listt[i + 1] - listt[i])
	print(min(listm))


n = int(input())
s = 0
for i in range(n):
	l = int(input())
	lst = list(map(int, input().split()))
	lst = sorted(lst)
	lst2 = [lst[i + 1] - lst[i] for i in range(l - 1)]
	lst2 = sorted(lst2)
	print(lst2[0])


import sys
input = sys.stdin.readline

def solve(a, b):
	side = min(max(a, b * 2), max(a * 2, b))
	return side * side
T = int(input())
for i in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	sort_a = sorted(a)
	answer = 1001
	for j in range(n):
		for k in range(j + 1, n):
			answer = min(answer, sort_a[k] - sort_a[j])
	print(answer)


from sys import stdin
from itertools import groupby

def inp():
	return stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	ar = [int(x) for x in inp().split()]
	minimum = max(ar)
	ar.sort()
	for i in range(len(ar) - 1):
		minimum = min(abs(ar[i] - ar[i + 1]), minimum)
	print(minimum)


def solve(n, s):
	s.sort()
	d = s[-1]
	for i in range(1, n):
		dif = s[i] - s[i - 1]
		if dif < d:
			d = dif
	return d
t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	print(solve(n, s))


n = int(input())
lii = []
for i in range(0, n):
	n1 = int(input())
	li = list(map(int, input().split()))
	x = len(li) - 1
	li.sort()
	mi = 99999
	for j in range(0, x):
		if mi > abs(li[j] - li[j + 1]):
			mi = abs(li[j] - li[j + 1])
	lii.append(mi)
	li = []
for i in range(0, n):
	print(lii[i])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	ans = a[1] - a[0]
	for i in range(2, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


for _ in range(int(input())):
	a = int(input())
	p = []
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	if len(set(l)) != len(l):
		print(0)
	else:
		for i in l:
			for k in l:
				if i != k and i - k >= 0:
					p.append(i - k)
		print(min(p))


kl = int(input())
for l in range(kl):
	n = int(input())
	a = [int(i) for i in input().split()]
	mn = 1000
	for i in range(n):
		for j in range(n):
			if i != j:
				mn = min(mn, abs(a[i] - a[j]))
	print(mn)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mi = a[1] - a[0]
	for i in range(1, n - 1):
		d = a[i + 1] - a[i]
		if d < mi:
			mi = d
	print(mi)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = list(map(int, input().split()))
		p = 1001
		for i in range(n - 1):
			for j in range(i + 1, n):
				k = abs(s[i] - s[j])
				if k < p:
					p = k
		print(p)
main()


from collections import defaultdict as dfd
import math
import sys
import heapq

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def main():
	for _ in range(II()):
		N = II()
		A = LI()
		C = []
		mini = float('inf')
		for i in range(len(A) - 1, 0, -1):
			for j in range(i - 1, -1, -1):
				if abs(A[j] - A[i]) < mini:
					mini = abs(A[j] - A[i])
		print(mini)
main()


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	sum = 99999999999
	for j in range(len(s) - 1):
		if abs(s[j] - s[j + 1]) < sum:
			sum = abs(s[j] - s[j + 1])
	print(sum)


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	mini = abs(a[1] - a[0])
	for i in range(1, n - 1):
		if abs(a[i + 1] - a[i]) < mini:
			mini = abs(a[i + 1] - a[i])
	print(mini)


for i in range(int(input())):
	x = int(input())
	minimum = 1000
	y = list(map(int, input().split()))
	y.sort()
	for k in range(x - 1):
		if y[k + 1] - y[k] < minimum:
			minimum = y[k + 1] - y[k]
	print(minimum)


def solve():
	n = int(input())
	l1 = list(map(int, input().split()))
	min1 = 10000000
	l1.sort()
	for i in range(n - 1):
		v = l1[i + 1] - l1[i]
		min1 = min(min1, v)
		if min1 == 0:
			print(0)
			return
	print(min1)
for _ in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	list1 = list(map(int, input().strip().split()))
	list1.sort()
	ans = 1000
	for i in range(1, n):
		diff = list1[i] - list1[i - 1]
		if diff < ans:
			ans = diff
	print(ans)


for i in range(int(input())):
	input()
	lis = list(map(int, input().split()))
	lis.sort()
	ans = 999999999999
	for i in range(len(lis) - 1):
		sub = lis[i + 1] - lis[i]
		if sub < ans:
			ans = sub
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = str(input()).split(' ')
	for j in range(n):
		a[j] = int(a[j])
	a.sort()
	l = []
	for i in range(n - 1):
		l.append(a[i + 1] - a[i])
	l.sort()
	print(l[0])


t = int(input())
for i in range(t):
	n = int(input())
	sportmen = list(map(int, input().split()))
	difference = 1000
	for j in range(n):
		for x in range(j + 1, n):
			if abs(sportmen[j] - sportmen[x]) < difference:
				difference = abs(sportmen[j] - sportmen[x])
	print(difference)


def solution(a):
	a.sort()
	s = 10 ** 9
	for i in range(len(a) - 1):
		s = min(s, a[i + 1] - a[i])
	print(s)
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	solution(l)


n = int(input())
arr = []
for i in range(n):
	x = int(input())
	c = list(map(int, input().split(' ')))
	arr.append(c.copy())

def merge(arr, start, mid, end):
	arr1 = []
	if end - start == 1:
		if arr[start] > arr[end]:
			arr1.append(arr[end])
			arr1.append(arr[start])
		else:
			arr1.append(arr[start])
			arr1.append(arr[end])
	else:
		i = start
		j = mid + 1
		while i <= mid and j <= end:
			if arr[i] > arr[j]:
				arr1.append(arr[j])
				j += 1
			elif arr[i] < arr[j]:
				arr1.append(arr[i])
				i += 1
			else:
				arr1.append(arr[i])
				arr1.append([arr[j]])
				i += 1
				j += 1
		if i <= mid:
			arr1.extend(arr[i:mid + 1])
		elif j <= end:
			arr1.extend(arr[j:end + 1])
	arr = arr[0:start] + arr1 + arr[end + 1:]
	return arr

def sort(arr, start, end):
	if start == end:
		return arr
	elif start > end:
		return
	else:
		mid = (start + end) // 2
		arr = sort(arr, start, mid)
		arr = sort(arr, mid + 1, end)
		arr = merge(arr, start, mid, end)
		return arr

def check(arr):
	l = len(arr) - 1
	d = {}
	for i in range(l):
		d[i] = arr[i + 1] - arr[i]
	return min(d.values())
for lst in arr:
	lst = sorted(lst)
	print(check(lst))


for t in range(int(input())):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	mini = s[1] - s[0]
	for i in range(1, n):
		mini = min(mini, s[i] - s[i - 1])
	print(mini)


for i in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	min = 999999
	for i in range(len(l) - 1):
		if l[i + 1] - l[i] < min:
			min = l[i + 1] - l[i]
	print(min)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	res = 10 ** 15
	for i in range(n - 1):
		res = min(res, abs(a[i] - a[i + 1]))
	print(res)


for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	prev = arr[0]
	res = float('inf')
	for num in arr[1:]:
		if abs(num - prev) < res:
			res = abs(num - prev)
		prev = num
	print(res)


tests = int(input())
for i in range(tests):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	min1 = 10000000
	for i in range(1, n):
		z = arr[i] - arr[i - 1]
		if min1 > z:
			min1 = z
	print(min1)


t = int(input())
for test in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	ans = 1000
	for i in range(1, n):
		delta = a[i] - a[i - 1]
		ans = min(ans, delta)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	r = []
	for i in range(n - 1):
		r.append(l[i + 1] - l[i])
	print(min(r))


import sys
import math
from collections import defaultdict as dd
mod = 1000000007
T = 1
T = int(sys.stdin.readline())
for _ in range(T):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = l[-1] - l[0]
	for i in range(1, n):
		if l[i] - l[i - 1] < ans:
			ans = l[i] - l[i - 1]
	print(ans)


n = int(input())
result = []
for _ in range(n):
	minDiff = 2048
	count = int(input())
	numbers = sorted([int(x) for x in input().split()])
	for i in range(len(numbers) - 1):
		if abs(numbers[i] - numbers[i + 1]) < minDiff:
			minDiff = abs(numbers[i] - numbers[i + 1])
	result.append(minDiff)
for x in range(len(result)):
	print(result[x])


cases = int(input())
for i in range(0, cases):
	lenth = int(input())
	listy = list(map(int, input().split()))
	listy.sort()
	diff = 10000000000
	for j in range(0, lenth - 1):
		temp = listy[j + 1] - listy[j]
		if temp < diff:
			diff = temp
	print(diff)


for i in range(int(input())):
	n = int(input())
	k = [int(x) for x in input().split()]
	k.sort()
	a = k[1] - k[0]
	for j in range(n - 1):
		b = k[j + 1] - k[j]
		if b == 0:
			a = 0
			break
		elif b < a:
			a = b
	print(a)


t = int(input())
for i in range(t):
	n = int(input())
	l = input().split(' ')
	l1 = list(map(int, l))
	l1.sort()
	val1 = 99999999
	for i in range(1, n):
		val2 = abs(max(l1[0:i]) - min(l1[i:n]))
		if val1 > val2:
			val2 = val2
			val1 = val2
		else:
			val2 = val1
	print(val1)


for i in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	m = 1000000
	for i in range(1, n):
		m = min(m, a[i] - a[i - 1])
		if m == 0:
			break
	print(m)


t = int(input())
for r in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = 0
	q = []
	p = min(l)
	m = max(l) - min(l)
	for i in range(n):
		q.append(l.count(l[i]))
	if n == 2:
		s = max(l) - min(l)
	elif max(q) >= 2:
		s = 0
	else:
		for i in range(n):
			for j in range(n):
				if i != j:
					w = abs(l[i] - l[j])
					if w < m:
						m = w
						s = m
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	S = [int(s) for s in input().split()]
	S.sort()
	ans = S[1] - S[0]
	for i in range(n - 1):
		ans = min(ans, S[i + 1] - S[i])
	print(ans)


def fun(arr):
	arr.sort()
	ans = 2 ** 31
	for i in range(len(arr) - 1):
		ans = min(ans, arr[i + 1] - arr[i])
	return ans
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(fun(arr))


for _ in range(int(input())):
	lens = int(input())
	arrs = sorted([int(x) for x in input().split()])
	ans = min([y - x for (x, y) in zip(arrs, arrs[1:])])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	inp = list(map(int, input().split()))
	sortar = sorted(inp)
	gap = 1000
	for i in range(n - 1):
		if sortar[i + 1] - sortar[i] < gap:
			gap = sortar[i + 1] - sortar[i]
		if gap == 0:
			break
	print(gap)


T = int(input())
II = 0
import math
while II < T:
	n = int(input())
	s = input().split()
	s = [int(d) for d in s]
	s.sort()
	s = [0] + s
	d = [s[i + 1] - s[i] for i in range(n)]
	print(min(d[1:]))
	II += 1


import math
for _ in [0] * int(input()):
	n = int(input())
	athlates = input().split()
	for i in range(0, n):
		athlates[i] = int(athlates[i])
	athlates.sort()
	ans = athlates[1] - athlates[0]
	for i in range(1, n):
		tmp = int(athlates[i] - athlates[i - 1])
		if tmp < ans:
			ans = tmp
	print(ans)


T = int(input())
for _ in range(0, T):
	N = int(input())
	S = list(map(int, input().split()))
	m = 10000000000000000
	for i in range(0, N - 1):
		for j in range(i + 1, N):
			m = min(m, abs(S[i] - S[j]))
	print(m)


t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	ans = 99999999
	arr.sort()
	for i in range(n - 1):
		for j in range(i + 1, n):
			ans = min(ans, abs(arr[i] - arr[j]))
	print(ans)


from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
import math
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()
rli = lambda : map(int, stdin.readline().split())
(INF, NINF) = (float('inf'), float('-inf'))

def main():
	T = int(rl())
	for _ in range(T):
		n = int(rl())
		A = list(rli())
		A.sort()
		ans = INF
		for i in range(len(A) - 1):
			ans = min(ans, abs(A[i] - A[i + 1]))
		print(ans)
	stdout.close()
main()


import sys
max_int = 1000000001
min_int = -max_int
t = int(input())
for _t in range(t):
	n = int(sys.stdin.readline())
	s = list(map(int, sys.stdin.readline().split()))
	ans = max_int
	s.sort()
	for i in range(1, len(s)):
		ans = min(ans, s[i] - s[i - 1])
	print(ans)


def good_pair_dif(arr):
	arr.sort()
	dif = float('inf')
	l = len(arr) - 1
	for num in range(l):
		curr_dif = abs(arr[num] - arr[num + 1])
		if curr_dif < dif:
			dif = curr_dif
	return dif

def main():
	for test in range(int(input())):
		_ = int(input())
		s = list(map(int, input().split()))
		result = good_pair_dif(s)
		print(result)
main()


N = int(input())
for i in range(N):
	a = int(input())
	team = list(map(int, input().strip().split()))
	rslt = 999
	team.sort()
	for i in range(len(team) - 1):
		if team[i + 1] - team[i] == 0:
			rslt = 0
			break
		elif team[i + 1] - team[i] < rslt:
			rslt = team[i + 1] - team[i]
	print(rslt)


a = int(input())
for i in range(a):
	b = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mini = 1000000000
	for i in range(len(l)):
		if i != len(l) - 1:
			if abs(l[i] - l[i + 1]) < mini:
				mini = abs(l[i] - l[i + 1])
	print(mini)


T = int(input())
for _ in range(T):
	n = int(input())
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	a.sort()
	mini = a[1] - a[0]
	for i in range(1, n):
		if a[i] - a[i - 1] < mini:
			mini = a[i] - a[i - 1]
		if mini == 0:
			break
	print(mini)


n = int(input())
while n > 0:
	l = int(input())
	arr = map(int, input().split())
	arr = sorted(arr)
	diff = float('inf')
	for i in range(1, len(arr)):
		diff = min(diff, abs(arr[i] - arr[i - 1]))
	print(diff)
	n -= 1


import sys
t = int(input())
while t > 0:
	n = int(input())
	num = input().split()
	d = sys.maxsize
	for i in range(n):
		for j in range(i + 1, n, 1):
			diff = int(num[i]) - int(num[j])
			if diff < 0:
				diff *= -1
			if diff < d:
				d = diff
	print(d)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	ar = sorted(list(map(int, input().split())))
	m = 100000.0
	for i in range(len(ar) - 1):
		m = min(ar[i + 1] - ar[i], m)
	print(m)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	minu = 100000
	for i in range(n - 1):
		if A[i + 1] - A[i] < minu:
			minu = A[i + 1] - A[i]
	print(minu)


t = int(input())
for i in range(t):
	n = int(input())
	s = sorted([int(i) for i in input().split()])
	m = 1001
	for i in range(1, n):
		m = min(m, s[i] - s[i - 1])
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	s = [int(i) for i in input().split(' ')]
	s.sort()
	ans = 99999999
	for k in range(1, len(s)):
		if s[k] - s[k - 1] < ans:
			ans = s[k] - s[k - 1]
	print(ans)


import math
t = int(input())
for i in range(t):
	n = int(input())
	athlates = map(int, input().split())
	maxx = math.ceil(n / 2)
	minn = maxx - 1
	athlates = sorted(athlates)
	x = athlates[0]
	ans = []
	for i in range(1, n):
		ans.append(athlates[i] - x)
		x = athlates[i]
	print(min(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	(*a,) = map(int, input().split())
	a.sort()
	a = [abs(a[i] - a[i + 1]) for i in range(n - 1)]
	print(min(a))


t = int(input())
for i in range(t):
	a = int(input())
	n = list(map(int, input().split()))
	n.sort()
	b = set(n)
	l = []
	if len(b) == a:
		for j in range(a):
			for k in range(j + 1, a):
				l.append(abs(n[j] - n[k]))
		print(min(l))
	else:
		print('0')


for _ in range(int(input())):
	z = float('inf')
	n = int(input())
	l = sorted(list(map(int, input().split())))
	for i in range(n - 1):
		ans = abs(l[i + 1] - l[i])
		z = min(z, ans)
	print(z)


import sys
q = int(input())
for i in range(q):
	n = int(sys.stdin.readline())
	a = [int(i) for i in sys.stdin.readline().split()]
	minrazn = 999999
	a.sort()
	for k in range(n - 1):
		if minrazn > a[k + 1] - a[k]:
			minrazn = a[k + 1] - a[k]
	print(minrazn)


n = int(input())
for i in range(n):
	n = int(input())
	ns = sorted(list(map(int, input().split())))
	res = ns[1] - ns[0]
	for i in range(1, n - 1):
		x = ns[i + 1] - ns[i]
		if x < res:
			res = x
	print(res)


n = int(input())
for i in range(n):
	athletes = int(input())
	arr = list(map(int, input().split()))
	count = 1000
	arr.sort()
	for j in range(len(arr) - 1):
		if abs(arr[j] - arr[j + 1]) < count:
			count = abs(arr[j] - arr[j + 1])
	print(count)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mn = float('inf')
	for i in range(n - 1):
		mn = min(mn, a[i + 1] - a[i])
	print(mn)


from sys import stdin, stdout

def main():
	t = int(stdin.readline())
	for _ in range(t):
		n = int(stdin.readline())
		arr = list(map(int, stdin.readline().split()))
		arr.sort()
		mn = -1
		for i in range(1, n):
			if mn == -1:
				mn = arr[i] - arr[i - 1]
				continue
			mn = min(arr[i] - arr[i - 1], mn)
		stdout.write(str(mn) + '\n')
main()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = []
	for i in range(n):
		for j in range(i + 1, n):
			b.append(a[j] - a[i])
	print(min(b))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = a[0]
	m = 1000000000000
	a.sort()
	for i in range(1, n):
		m = min(m, abs(a[i] - a[i - 1]))
	print(m)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	m = 999999999999999999999
	for i in range(n):
		for j in range(i + 1, n):
			x = abs(a[i] - a[j])
			if x < m:
				m = x
	print(m)
	t -= 1


t = int(input())
for _ in range(t):
	teamA = []
	teamB = []
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	diff = max(a)
	for i in range(n - 1):
		if a[i + 1] - a[i] < diff:
			diff = a[i + 1] - a[i]
		else:
			pass
	print(diff)


import sys
from math import tan, pi, cos, sin
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
from itertools import islice, cycle

def go():
	n = int(input())
	s = sorted(map(int, input().split()))
	best = s[-1] - s[0]
	for i in range(n - 1):
		best = min(best, s[i + 1] - s[i])
	return best
t = int(input())
ans = []
for _ in range(t):
	ans.append(str(go()))
print('\n'.join(ans))


for i in range(int(input())):
	n = int(input())
	s = [int(q) for q in input().split()]
	s.sort()
	difflist = []
	for i in range(1, n):
		diff = s[i] - s[i - 1]
		difflist.append(diff)
	print(min(difflist))


n = int(input())
for i in range(n):
	a = int(input())
	l = [int(k) for k in input().split()]
	l.sort()
	min_ = l[1] - l[0]
	for j in range(1, a - 1):
		x = l[j + 1] - l[j]
		if x < min_:
			min_ = x
	print(min_)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	m = 1000
	for i in range(1, len(s)):
		m = min(m, abs(s[i] - s[i - 1]))
	print(m)


for i in range(int(input())):
	a = int(input())
	b = sorted(list(map(int, input().split())))
	r = b[-1]
	for i in range(1, a):
		p = b[i] - b[i - 1]
		if r > p:
			r = p
	print(r)


import collections, heapq, itertools, math, functools
groupby = itertools.groupby
rs = lambda : input()
ri = lambda : int(input())
rm = lambda : map(int, input().split())
rai = lambda : [int(x) for x in input().split()]

def solve():
	a.sort()
	ans = float('inf')
	for i in range(1, len(a)):
		ans = min(ans, a[i] - a[i - 1])
	return ans
for t in range(ri()):
	n = ri()
	a = rai()
	print(solve())


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mini = 19999
	for i in range(1, n):
		if arr[i] - arr[i - 1] < mini:
			mini = abs(arr[i] - arr[i - 1])
	print(mini)


for _ in range(int(input())):
	n = int(input())
	ans = 10000
	a = sorted([int(x) for x in input().split()])
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


cases = int(input())
answers = [10000] * cases
for i in range(cases):
	numAthletes = int(input())
	athletes = input().split()
	for j in range(numAthletes):
		athletes[j] = int(athletes[j])
	athletes.sort()
	for j in range(numAthletes - 1):
		if abs(athletes[j] - athletes[j + 1]) < answers[i]:
			answers[i] = abs(athletes[j] - athletes[j + 1])
for i in range(cases):
	print(answers[i])


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	mi = li[1] - li[0]
	for i in range(2, n):
		if li[i] - li[i - 1] < mi:
			mi = li[i] - li[i - 1]
	print(mi)


t = int(input())
for test in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	min = 10000
	for i in range(1, n):
		if min > arr[i] - arr[i - 1]:
			min = arr[i] - arr[i - 1]
	print(min)


cases = int(input())
for i in range(cases):
	n = int(input())
	line2 = input().split(' ')
	arr = []
	for a in line2:
		arr.append(int(a))
	arr.sort()
	diff = arr[-1] - arr[0]
	for b in range(len(arr) - 1):
		ele = arr[b]
		elenext = arr[b + 1]
		temp = abs(ele - elenext)
		diff = min(temp, diff)
	print(diff)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def solve(t):
	n = int(input().strip())
	data = list(map(int, input().strip().split()))
	data.sort()
	min_diff = min((abs(data[i] - data[i - 1]) for i in range(1, n)))
	return min_diff

def main():
	tc = int(input().strip())
	for t in range(1, tc + 1):
		print(solve(t))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	res = []
	d = 0
	for i in range(1, n):
		d = a[i] - a[i - 1]
		res.append(d)
	res.sort()
	print(res[0])


try:
	import math
	t = int(input())
	while t:
		n = int(input())
		l = list(map(int, input().split()))
		l.sort()
		mi = 99999
		for i in range(len(l) - 1):
			if l[i] - l[i + 1] == 0:
				mi = 0
				break
			elif abs(l[i] - l[i + 1]) < mi:
				mi = abs(l[i] - l[i + 1])
		print(mi)
		t = t - 1
except:
	pass


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	new = sorted(s)
	cnt = new[::-1]
	k = []
	for i in range(0, n - 1):
		k.append(cnt[i] - cnt[i + 1])
	print(min(k))


t = int(input())
for _ in range(t):
	n = int(input())
	strength = sorted(map(int, input().split()))
	if len(set(strength)) != n:
		print(0)
	else:
		lst = list(strength)
		result = strength[n - 1] - strength[0]
		for i in range(1, n):
			result = min(result, lst[i] - lst[i - 1])
		print(result)


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from copy import deepcopy

def solution(a, n):
	a.sort()
	min_diff = 10 ** 10
	for i in range(1, n):
		min_diff = min(min_diff, a[i] - a[i - 1])
	return min_diff

def main():
	T = read_int()
	for i in range(T):
		n = read_int()
		a = read_int_array()
		x = solution(a, n)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


for i in range(int(input())):
	n = int(input())
	lst = sorted(list(map(int, input().split())))
	m = float('inf')
	for i in range(n - 1):
		m = min(m, abs(lst[i] - lst[i + 1]))
	print(m)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s = sorted(s)
	minn = float('inf')
	for i in range(1, n):
		minn = min(minn, abs(s[i] - s[i - 1]))
	print(minn)


def solve(n, a):
	a.sort()
	ans = a[n - 1] + 1
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	solve(n, a)


t = int(input())
for _ in range(t):
	n = int(input())
	mans = [int(x) for x in input().split()]
	mans.sort()
	result = mans[n - 1] - mans[0]
	for i in range(n):
		for j in range(i + 1, n):
			result = min(result, abs(mans[i] - mans[j]))
	print(result)


def solve(athletes, length):
	s1 = sorted(athletes)
	differences = []
	for e in range(1, length, 1):
		differences.append(abs(s1[e] - s1[e - 1]))
	return min(differences)
t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	print(solve(s, n))


def solve():
	a = sorted(s)
	diffs = [a[i + 1] - a[i] for i in range(n - 1)]
	print(min(diffs))
	return
t = int(input())
for i in range(t):
	n = int(input())
	s = [int(i) for i in input().split()]
	solve()


for _ in range(int(input())):
	n = int(input())
	lt = list(map(int, input().split()))
	mn = abs(lt[0] - lt[1])
	for i in range(n):
		cpr = lt[i]
		for j in range(i + 1, n):
			mn = min(mn, abs(cpr - lt[j]))
	print(mn)


t = int(input())
for hh in range(0, t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	mindiff = 1000000
	for i in range(0, n - 1):
		diff = a[i + 1] - a[i]
		mindiff = min(mindiff, diff)
	print(mindiff)


for case in range(int(input())):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	mn = s[1] - s[0]
	for i in range(2, n):
		mn = min(mn, s[i] - s[i - 1])
	print(mn)


t = int(input())
for i in range(t):
	n = int(input())
	v = list(map(int, input().split(' ')))
	v.sort(reverse=False)
	ans = float('inf')
	for j in range(n - 1):
		ans = min(ans, v[j + 1] - v[j])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	ath = list(map(int, input().split()))
	ath.sort()
	diff = ath[-1]
	for i in range(len(ath) - 1):
		if abs(ath[i] - ath[i + 1]) < diff:
			diff = abs(ath[i] - ath[i + 1])
	print(diff)


def bubble_sort(a):
	p = 0
	for i in range(len(a) - 1, -1, -1):
		for j in range(i):
			if a[j] < a[j + 1]:
				(a[j + 1], a[j]) = (a[j], a[j + 1])
				p = 1
		if p == 0:
			return a
	return a
t = int(input())
out = []
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	bs = bubble_sort(b)
	d = []
	for i in range(len(bs) - 1):
		d.append(bs[i] - bs[i + 1])
	out.append(min(d))
for i in out:
	print(i)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)[::-1]
	mina = a[0] - a[1]
	for i in range(n - 1):
		mina = min(mina, a[i] - a[i + 1])
	print(mina)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	a.sort()
	mi = abs(a[1] - a[0])
	for i in range(1, len(a)):
		b = abs(a[i] - a[i - 1])
		if a.count(a[i]) >= 2:
			mi = 0
			break
		if mi > b:
			mi = b
	print(mi)


ans = []
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = sorted(l)
	li = [0] * (n - 1)
	for i in range(1, len(x)):
		li[i - 1] = x[i] - x[i - 1]
	ans.append(min(li))
ans = list(map(str, ans))
print('\n'.join(ans))


from __future__ import division, print_function
mod = int(1000000000.0 + 7)
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def nextPerfectSquare(N):
	nextN = math.floor(math.sqrt(N)) + 1
	return nextN * nextN

def main():
	for _ in range(inin()):
		n = inin()
		a = ain()
		a.sort()
		x = len(a)
		temp = a[1] - a[0]
		for i in range(n - 1):
			if temp >= a[i + 1] - a[i]:
				temp = a[i + 1] - a[i]
		print(temp)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = float('inf')
	for i in range(n):
		for j in range(i + 1, n):
			ans = min(ans, abs(a[i] - a[j]))
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = l[-1]
	for _ in range(n - 1):
		a = l[_ + 1] - l[_]
		if a < ans:
			ans = a
	print(ans)


for i in range(int(input())):
	n = int(input())
	ath = sorted([int(x) for x in input().split()])[0:n]
	k = 0
	if len(set(ath)) == n:
		for j in range(n - 1):
			diff = abs(ath[j] - ath[j + 1])
			if j == 0:
				k = diff
			elif diff < k:
				k = diff
			if j == n - 2:
				print(k)
	else:
		print(0)


t = int(input())
for q in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = a[1] - a[0]
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


n = int(input())
for _ in range(n):
	input()
	nums = list(map(int, input().split()))
	nums.sort()
	res = nums[len(nums) - 1]
	for i in range(1, len(nums)):
		res = min(res, nums[i] - nums[i - 1])
	print(res)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	min_diff = 100000.0
	for i in range(n):
		for j in range(i + 1, n):
			diff = abs(arr[j] - arr[i])
			if diff < min_diff:
				min_diff = diff
	print(min_diff)


t = int(input())
for w in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	arr1 = set(arr)
	if len(arr) < n:
		print(0)
	else:
		i = 0
		m = 100000000000
		while i < n - 1:
			j = i + 1
			while j < n:
				m = min(m, abs(arr[i] - arr[j]))
				j += 1
			i += 1
		print(m)


from math import ceil, sqrt
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort()
	minDif = arr[1] - arr[0]
	for index in range(1, len(arr)):
		minDif = min(minDif, abs(arr[index] - arr[index - 1]))
	print(minDif)


for _ in range(int(input())):
	a = int(input())
	z = sorted(list(map(int, input().split())))
	if len(set(z)) != a:
		print(0)
	else:
		x = 1000
		for i in range(1, a):
			q = abs(z[i] - z[i - 1])
			if q < 2:
				x = 1
				break
			else:
				x = min(x, q)
		print(x)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	minDiff = 1001
	for i in range(n - 1):
		if s[i + 1] - s[i] < minDiff:
			minDiff = s[i + 1] - s[i]
	print(minDiff)


t = int(input())
for q in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	res = 1001
	p = []
	for i in range(len(l)):
		if i in p:
			res = 0
			break
		p.append(i)
		for j in range(i + 1, len(l)):
			res = min(res, abs(l[i] - l[j]))
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, list(input().split())))
	s.sort()
	ans = 199999999
	d = {}
	for i in range(n - 1):
		ans = min(ans, s[i + 1] - s[i])
		d[s[i]] = d.get(s[i], 0) + 1
		if d[s[i]] > 1:
			ans = 0
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ma = 10 ** 10
	for i in range(n - 1):
		if l[i + 1] - l[i] < ma:
			ma = l[i + 1] - l[i]
	print(ma)


for _ in range(int(input())):
	p = input()
	k = list(map(int, input().split()))
	k.sort()
	i = len(k) - 1
	m = []
	while i > 0:
		m.append(k[i] - k[i - 1])
		if k[i] - k[i - 1] == 0:
			break
		i -= 1
	print(min(m))


case_n = int(input())
ans = []
for i in range(case_n):
	ath_n = int(input())
	athlist = list(map(int, input().split(' ')))
	athlist = sorted(athlist)
	diff = []
	for j in range(1, len(athlist)):
		diff.append(athlist[j] - athlist[j - 1])
	ans.append(min(diff))
for x in ans:
	print(x)


t = int(input())
for i in range(t):
	n = int(input())
	s = sorted(map(int, input().split()))
	_min = s[1] - s[0]
	for i in range(2, n):
		curr = s[i] - s[i - 1]
		if curr < _min:
			_min = curr
	print(_min)


import sys
import os
import heapq
try:
	path = './file/input.txt'
	if os.path.exists(path):
		sys.stdin = open(path, 'r')
except:
	pass
t = int(input())

def printd(value):
	pass
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	arr.sort()
	result = 20000
	for i in range(1, n):
		value = arr[i] - arr[i - 1]
		if value < result:
			result = value
	print(result)


import math

class Solution:

	def __init__(self):
		test = int(input())
		for i in range(0, test):
			n = int(input())
			s = list(map(int, input().split()))
			self.solve(n, s)

	def solve(self, n, s):
		s.sort()
		res = math.inf
		for i in range(1, n):
			res = min(res, s[i] - s[i - 1])
		print(res)
Solution()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))[:n]
	a.sort()
	diff = 2 ** 31 - 1
	for i in range(1, n):
		diff = min(diff, a[i] - a[i - 1])
	print(diff)


import sys
input = sys.stdin.readline
from math import *

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	a = int_array()
	a.sort()
	ans = INF
	for i in range(n - 1):
		ans = min(abs(a[i] - a[i + 1]), ans)
	print(ans)


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, S):
	S.sort()
	best = float('inf')
	for (x, y) in zip(S, S[1:]):
		best = min(best, y - x)
	return best
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N,) = [int(x) for x in input().split()]
	S = [int(x) for x in input().split()]
	ans = solve(N, S)
	print(ans)


test = int(input())
for t in range(test):
	n = int(input())
	a = list(map(int, input().split()))
	s = set(a)
	if len(list(s)) != len(a):
		print(0)
	else:
		a.sort()
		m = 10000
		for i in range(1, n):
			diff = a[i] - a[i - 1]
			if m > diff:
				m = diff
		print(m)


def read():
	return list(map(int, input().split()))
for i in range(int(input())):
	n = int(input())
	arr = read()
	t = float('inf')
	arr = sorted(arr)
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < t:
			t = arr[i + 1] - arr[i]
	print(t)


from collections import defaultdict, Counter
import copy, math
from copy import deepcopy
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	s = 9999999999
	for i in range(1, n):
		s = min(s, abs(l[i] - l[i - 1]))
	print(s)


for _ in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	list1.sort()
	min1 = list1[1] - list1[0]
	for i in range(1, len(list1) - 1):
		if list1[i + 1] - list1[i] < min1:
			min1 = list1[i + 1] - list1[i]
	print(min1)


cases = int(input())
for _ in range(cases):
	n = int(input())
	c = list(map(int, input().split()))
	mini = 100000000
	for i in range(len(c) - 1):
		for j in range(i + 1, len(c)):
			mini = min(mini, abs(c[i] - c[j]))
	print(mini)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mindiff = 2000
	for i in range(n - 1):
		mindiff = min(mindiff, abs(a[i] - a[i + 1]))
	print(mindiff)


t = int(input())
for _ in range(0, t):
	n = int(input())
	ss = sorted([int(i) for i in input().split()])
	ans = 10 ** 9 + 7
	for i in range(1, n):
		ans = min(ans, ss[i] - ss[i - 1])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	t = [*map(int, input().split())]
	t.sort()
	mini = 10 ** 6 + 1
	for i in range(n - 1):
		mini = min(mini, t[i + 1] - t[i])
	print(mini)


t = int(input())
for y in range(t):
	d = {}
	n = int(input())
	s = input().split()
	minDiff = float('inf')
	for i in range(n):
		a = int(s[i])
		for j in range(n):
			b = int(s[j])
			if i != j:
				minDiff = min(minDiff, abs(a - b))
	print(minDiff)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	mi = a[-1]
	for i in range(1, n):
		mi = min(mi, a[i] - a[i - 1])
	print(mi)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	ans = float('inf')
	for i in range(n - 1):
		ans = min(ans, arr[i + 1] - arr[i])
	print(ans)


for t in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	m = 10000
	for i in range(n - 1):
		m = min(m, a[i + 1] - a[i])
	print(m)


t = int(input())
l = []
for i in range(t):
	n = int(input())
	s = input().split()
	s = [int(j) for j in s]
	s.sort()
	d = []
	for j in range(n - 1):
		d.append(s[j + 1] - s[j])
	d.sort()
	l.append(d[0])
for i in l:
	print(i)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr = sorted(arr)
	diff = [arr[i + 1] - arr[i] for i in range(n - 1)]
	min = float('inf')
	for i in range(n - 1):
		if diff[i] < min:
			min = diff[i]
	print(min)


T = int(input())
for _ in range(T):
	N = int(input())
	S = sorted(map(int, input().split()))
	ans = S[1] - S[0]
	for i in range(2, N):
		ans = min(ans, S[i] - S[i - 1])
	print(ans)


test = int(input())
while test > 0:
	test = test - 1
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	t = []
	d = 0
	for i in range(n - 1):
		d = abs(li[i] - li[i + 1])
		t.append(d)
	print(min(t))


for i in range(int(input())):
	n = int(input())
	s = [i for i in sorted([int(i) for i in input().split()])]
	mini = max(s)
	for i in range(n - 1):
		m = s[i + 1] - s[i]
		if m < mini:
			mini = m
	print(mini)


n = int(input())
for _ in range(n):
	m = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = s[1] - s[0]
	for i in range(m - 1):
		if s[i + 1] - s[i] < ans:
			ans = s[i + 1] - s[i]
	print(ans)


T = int(input())
for t in range(T):
	n = int(input())
	A = sorted([int(i) for i in input().split()])
	print(min([A[i] - A[i - 1] for i in range(1, n)]))


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' ', end='\n'):
	print(sep.join(map(str, a)), end=end)

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
for _ in range(ii()):
	n = ii()
	d = li()
	d.sort()
	res = 10 ** 5
	for i in range(1, n):
		res = min(res, d[i] - d[i - 1])
	print(res)


from sys import stdin, stdout
cases = int(stdin.readline())
for case in range(cases):
	n = int(stdin.readline())
	athletes = sorted([int(x) for x in stdin.readline().split()])
	lowDiff = float('inf')
	for a in range(n - 1):
		lowDiff = min(lowDiff, abs(athletes[a] - athletes[a + 1]))
	print(lowDiff)


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	diff = 10000
	for i in range(n - 1, 0, -1):
		diff = min(diff, a[i] - a[i - 1])
	print(diff)


n = int(input())
for i in range(0, n):
	n1 = int(input())
	l1 = list(map(int, input().split()))
	l = sorted(l1)
	mini = l[n1 - 1] - l[0]
	for j in range(0, n1):
		for k in range(j + 1, n1):
			mini = min(mini, l[k] - l[j])
	print(mini)


t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted(map(int, input().split()))
	print(min([i - j for (i, j) in zip(s[1:], s[:-1])]))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	diff = abs(l[-1] - l[0])
	for i in range(n):
		for j in range(i + 1, n):
			diff = min(diff, abs(l[i] - l[j]))
	print(diff)


T = int(input())
for i in range(T):
	N = int(input())
	lst = []
	lst = list(map(int, input().split()))[:N]
	lst.sort()
	temp = []
	for i in range(len(lst) - 1):
		temp.append(lst[i + 1] - lst[i])
	print(min(temp))


T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	Min = 10000000000
	for i in range(1, n):
		Min = min(Min, abs(arr[i] - arr[i - 1]))
	print(Min)


def minDiff(arr, n):
	arr = sorted(arr)
	diff = 10 ** 22
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < diff:
			diff = arr[i + 1] - arr[i]
	return diff
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	l = len(arr)
	print(minDiff(arr, l))


def solution():
	n = int(input())
	a = sorted(list(map(lambda x: int(x), input().split())))
	answer = 100000000000
	for i in range(n - 1):
		answer = min(answer, a[i + 1] - a[i])
	print(answer)
t = int(input())
for _ in range(t):
	solution()


t = int(input())
for x in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr = sorted(arr, reverse=True)
	min_val = 10000
	for i in range(0, len(arr) - 1):
		diff = arr[i] - arr[i + 1]
		if diff < min_val:
			min_val = diff
		if diff == 0:
			break
	print(min_val)


import math
t = int(input())
for k in range(t):
	n = int(input())
	s = [int(j) for j in input().split()]
	minimum = float('inf')
	for i in range(n):
		for j in range(n):
			if i != j:
				minimum = min(minimum, abs(s[i] - s[j]))
	print(minimum)


from sys import stdin, stdout
import math
from collections import Counter, deque
L = lambda : list(map(int, stdin.readline().strip().split()))
M = lambda : map(int, stdin.readline().strip().split())
I = lambda : int(stdin.readline().strip())
IN = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()
mod = 1000000007

def s(a):
	print(' '.join(list(map(str, a))))
for i in range(I()):
	n = I()
	a = sorted(L())
	m = a[1] - a[0]
	for i in range(n - 1):
		m = min(m, a[i + 1] - a[i])
	print(m)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	j = 2
	ans = arr[1] - arr[0]
	while j < len(arr):
		test = arr[j] - arr[j - 1]
		if test < ans:
			ans = test
		j = j + 1
	print(ans)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	n = ii1()
	s = sorted(iia())
	res = float('inf')
	for i in range(1, n):
		res = min(res, abs(s[i] - s[i - 1]))
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	k = []
	for i in range(n - 1):
		k.append(abs(a[i] - a[i + 1]))
	print(min(k))


T = int(input())
for _ in range(T):
	n = int(input())
	athletes = list(map(int, input().split()))
	new = []
	for i in range(len(athletes)):
		for j in range(i + 1, len(athletes)):
			new.append(abs(athletes[i] - athletes[j]))
	print(min(new))


outputs = []
for __ in range(int(input())):
	input()
	A = [int(num) for num in input().split()]
	A.sort()
	diff = set()
	for (index, num) in enumerate(A):
		if index != 0:
			diff.add(num - A[index - 1])
	outputs.append(min(diff))
for output in outputs:
	print(output)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a = sorted(a)
	minn = 1001
	for i in range(1, n):
		if a[i] - a[i - 1] < minn:
			minn = a[i] - a[i - 1]
	print(minn)


for _ in range(int(input())):
	n = int(input())
	S = [int(num) for num in input().split()]
	m = float('inf')
	for (i, num1) in enumerate(S):
		for num2 in S[i + 1:]:
			diff = abs(num1 - num2)
			m = min(m, diff)
	print(m)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	diff = float('inf')
	for pos in range(n):
		for pos2 in range(pos + 1, n):
			if abs(arr[pos] - arr[pos2]) < diff:
				diff = abs(arr[pos] - arr[pos2])
	print(diff)


t = int(input())
for _ in range(t):
	n = int(input())
	x = [int(i) for i in input().split()]
	x.sort()
	for i in range(n - 1):
		x[i] = x[i + 1] - x[i]
	x.pop(-1)
	print(min(x))


from sys import maxsize
t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted([int(num) for num in input().split()])
	minimum = maxsize
	for i in range(n - 1):
		minimum = min(minimum, s[i + 1] - s[i])
	print(minimum)


t = int(input())
while t > 0:
	n = input()
	arr = [int(x) for x in input().strip().split()]
	arr.sort()
	ans = arr[len(arr) - 1] - arr[0]
	for i in range(1, len(arr)):
		ans = min(ans, abs(arr[i] - arr[i - 1]))
	print(ans)
	t -= 1


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		ans = 1e+18
		for i in range(n - 1):
			for j in range(i + 1, n):
				ans = min(ans, abs(a[i] - a[j]))
		print(ans)
main()


n = int(input())
o = []
for i in range(n):
	m = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	o += [str(min((l[i + 1] - l[i] for i in range(m - 1))))]
print('\n'.join(o))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	m = 2 ** 31
	for i in range(n - 1):
		s = a[i + 1] - a[i]
		if s < m:
			m = s
	print(m)


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	minx = 2 ** 32
	t1 = 0
	t2 = 0
	for i in range(n):
		for j in range(n):
			if i != j and minx > min(minx, abs(x[i] - x[j])):
				minx = min(minx, abs(x[i] - x[j]))
	print(minx)


T = int(input())
for _ in range(T):
	a = int(input())
	hh = sorted(map(int, input().split()))
	ans = 10 ** 10
	for (h1, h2) in zip(hh[:-1], hh[1:]):
		ans = min(ans, h2 - h1)
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	s = sorted(a)
	print(min([s[i + 1] - s[i] for i in range(n - 1)]))


t = int(input())
while t:
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	mini = 999999999
	for i in range(n - 1):
		if s[i + 1] - s[i] < mini:
			mini = s[i + 1] - s[i]
	print(mini)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	num1 = list(map(int, input().split()))
	num1.sort()
	num2 = []
	for j in range(1, n):
		num2.append(num1[j] - num1[j - 1])
	print(min(num2))


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	b = []
	for x in range(1, n):
		b.append(a[x] - a[x - 1])
	b.sort()
	print(b[0])


import math
from math import gcd
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 1001
	for i in range(1, n):
		ans = min(ans, l[i] - l[i - 1])
	print(ans)


for _ in range(int(input())):
	t = int(input())
	n = list(map(int, input().split()))
	n.sort()
	min = float('+inf')
	for i in range(len(n) - 1):
		if n[i + 1] - n[i] < min:
			min = n[i + 1] - n[i]
	print(min)


n = int(input())
for i in range(n):
	k = int(input())
	x = list(map(int, input().split()))
	x.sort()
	m = x[-1]
	for j in range(1, len(x)):
		if m > x[j] - x[j - 1]:
			m = x[j] - x[j - 1]
	print(m)


def honestcoach(arr):
	ans = 1000
	for i in range(len(arr)):
		for j in range(i + 1, len(arr)):
			ans = min(ans, abs(arr[i] - arr[j]))
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(honestcoach(arr))


import sys
buff_readline = sys.stdin.readline
readline = sys.stdin.readline
INF = 2 ** 62 - 1

def read_int():
	return int(buff_readline())

def read_int_n():
	return list(map(int, buff_readline().split()))

def slv(N, S):
	S.sort()
	ans = INF
	for i in range(N - 1):
		ans = min(ans, abs(S[i] - S[i + 1]))
	return ans

def main():
	T = read_int()
	for _ in range(T):
		N = read_int()
		S = read_int_n()
		print(slv(N, S))
main()


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = []
	z = 0
	for i in range(n - 1):
		c = int(a[i + 1] - a[i])
		if c == 0:
			z = 1
			break
		else:
			ans.append(int(a[i + 1] - a[i]))
	if z == 1:
		print('0')
	else:
		print(min(ans))
	t -= 1


t = int(input())
while t > 0:
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	min = 1000
	for i in range(n - 1):
		if abs(l[i] - l[i + 1]) < min:
			min = abs(l[i] - l[i + 1])
	print(min)
	t -= 1


t = int(input())
while t:
	t -= 1
	num = int(input())
	data = list(map(int, input().split()))
	data = sorted(data)
	dic = {}
	diff = []
	even = False
	for i in range(len(data) - 1):
		diff.append(abs(data[i] - data[i + 1]))
		if data[i] not in dic:
			dic.setdefault(data[i], 1)
		else:
			even = True
			print(0)
			break
	if even == False:
		print(min(diff))


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().strip().split(' ')))
	lst.sort()
	lst1 = []
	for j in range(n - 1):
		lst1.append(lst[j + 1] - lst[j])
	print(min(lst1))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	minm = l[0]
	for j in range(n - 1):
		a = l[j] - l[j + 1]
		if minm > a:
			minm = a
	print(minm)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	mini = arr[0] - arr[1]
	for j in range(0, len(arr) - 1):
		a = arr[j] - arr[j + 1]
		if a < mini:
			mini = a
	print(mini)


for _ in range(int(input())):
	n = int(input())
	team = list(sorted(map(int, input().split()), reverse=True))
	m = team[0] + 1
	for i in range(n - 1):
		if team[i] - team[i + 1] < m:
			m = abs(team[i] - team[i + 1])
	print(m)


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	lt = [int(x) for x in input().split()]
	diff = 10001
	lt.sort()
	for i in range(1, n):
		diff = min(diff, abs(lt[i] - lt[i - 1]))
	print(diff)


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	diff = 0
	min1 = max(arr)
	for i in range(1, n):
		diff = arr[i] - arr[i - 1]
		if min1 > diff:
			min1 = diff
	print(min1)
	t -= 1


t = int(input())
for q in range(t):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	m = 1000
	for i in range(1, n):
		if s[i] - s[i - 1] < m:
			m = s[i] - s[i - 1]
	print(m)


testcase = int(input())
for test in range(testcase):
	n = int(input())
	ath = list(map(int, input().split()))
	ath.sort()
	diff = 10 ** 18
	for i in range(n - 1):
		diff = min(diff, ath[i + 1] - ath[i])
	print(diff)


t = int(input())
while t:
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	diff = li[1] - li[0]
	for i in range(1, n - 1):
		m = li[i + 1] - li[i]
		diff = min(diff, m)
	print(diff)
	t -= 1


strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
for t in range(int(input())):
	n = int(input())
	arr = intInp()
	arr.sort()
	m = 10 ** 9 + 1
	for i in range(n - 1):
		m = min(m, arr[i + 1] - arr[i])
	print(m)


for t in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	ans = float('inf')
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


t = int(input())
import heapq, copy
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))[:n]
	min_count = float('inf')
	heapq.heapify(arr)
	a = heapq.heappop(arr)
	while arr:
		b = heapq.heappop(arr)
		if min_count > b - a:
			min_count = b - a
		if min_count == 0:
			break
		a = copy.deepcopy(b)
	print(min_count)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	d = a[-1] - a[0]
	for i in range(1, n):
		d = min(a[i] - a[i - 1], d)
	print(d)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	diff = 1000000000
	for j in range(1, n):
		if a[j] - a[j - 1] < diff:
			diff = a[j] - a[j - 1]
	print(diff)


try:
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, input().split()))
		l.sort()
		m = []
		for i in range(n - 1):
			m.append(l[i + 1] - l[i])
		print(min(m))
except:
	pass


def solve(s, n):
	s = sorted(s)
	ans = 10000.0
	for i in range(1, n):
		if ans > abs(s[i] - s[i - 1]):
			ans = abs(s[i] - s[i - 1])
	return ans

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		s = list(map(int, input().split()))
		print(solve(s, n))
main()


t = int(input())
while t != 0:
	n = int(input())
	A = sorted(list(map(int, input().split())))
	i = 1
	tmp = A[1] - A[0]
	while i < n:
		if A[i] - A[i - 1] < tmp:
			tmp = A[i] - A[i - 1]
		i += 1
	print(tmp)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	s = arr[1] - arr[0]
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < s:
			s = arr[i + 1] - arr[i]
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	num = list(map(int, input().split()))
	num.sort()
	p = num[1] - num[0]
	for j in range(1, len(num) - 1):
		ans = num[j + 1] - num[j]
		if p > min(ans, p):
			p = num[j + 1] - num[j]
	print(p)


test = int(input())
for i in range(test):
	n = int(input())
	numlist = input().split()
	numlist = list(map(int, numlist))
	numlist.sort()
	diff = numlist[1] - numlist[0]
	for j in range(n - 1):
		dummy = numlist[j + 1] - numlist[j]
		if dummy < diff:
			diff = dummy
	print(diff)


import sys
q = int(sys.stdin.readline())
for _ in range(q):
	n = int(sys.stdin.readline())
	s = list(map(int, sys.stdin.readline().split()))
	minVal = sys.maxsize
	s = sorted(s)
	for i in range(n - 1):
		minVal = min(minVal, abs(s[i] - s[i + 1]))
	print(minVal)


def algo(a, n):
	ans = 10000000
	a.sort()
	for i in range(1, n):
		l = list(a[0:i])
		l1 = list(a[i:n])
		c = max(l)
		d = min(l1)
		ans = min(abs(c - d), ans)
	return ans
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(algo(a, n))


for _ in range(int(input())):
	n = int(input())
	ai = list(map(int, input().split()))
	lst = []
	for i in range(len(ai)):
		for j in range(len(ai)):
			if i != j:
				lst.append(abs(ai[i] - ai[j]))
	print(min(lst))


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		a.sort()
		m = 10005
		for (idx, i) in enumerate(a[:-1]):
			if abs(i - a[idx + 1]) < m:
				m = abs(i - a[idx + 1])
		print(m)
	return
main()


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s = sorted(s)
	ans = 10 ** 18
	for i in range(n - 1):
		ans = min(ans, s[i + 1] - s[i])
	print(ans)


tests = int(input())
for i in range(tests):
	n = int(input())
	powers = [int(x) for x in input().split()]
	powers.sort()
	result = powers[1] - powers[0]
	for x in range(n - 1):
		step = powers[x + 1] - powers[x]
		if step < result:
			result = step
	print(result)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	s = 10 ** 9
	for i in range(1, n):
		s = min(s, abs(a[i] - a[i - 1]))
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	min = 1001
	for i in range(1, len(A)):
		if A[i] - A[i - 1] < min:
			min = A[i] - A[i - 1]
			if min == 0:
				break
	print(min)


import sys
import math
import itertools
import random
from collections import deque

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = a[0]
	for i in range(len(a) - 1):
		if i == 0:
			ans = a[i + 1] - a[i]
		else:
			ans = min(ans, a[i + 1] - a[i])
	print(ans)
t = int(input())
while t > 0:
	solve()
	t -= 1


t = int(input())
for jn in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	mn = 1001
	for i in range(n - 1):
		mn = min(mn, s[i + 1] - s[i])
	print(mn)


from math import sqrt
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	m = s[-1]
	for i in range(len(s) - 1):
		if abs(s[i] - s[i + 1]) < m:
			m = abs(s[i] - s[i + 1])
	print(m)


t = int(input())
for i in range(t):
	input()
	a = list(map(int, input().split()))
	a.sort()
	s = 1000000000.0
	for j in range(len(a) - 1):
		if a[j + 1] - a[j] < s:
			s = a[j + 1] - a[j]
	print(s)


testCases = int(input())
for i in range(testCases):
	minValues = []
	numbers = int(input())
	athletes = sorted(list(map(int, input().split())))
	for i in range(numbers - 1):
		minValues.append(athletes[i + 1] - athletes[i])
	print(min(minValues))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	best = 999999999
	if len(set(a)) != len(a):
		print(0)
		continue
	else:
		a.sort()
		for i in range(0, len(a) - 1):
			best = min(best, abs(a[i] - a[i + 1]))
	print(best)


t = input()
t = int(t)
shetchikshetchikov1 = 0
while shetchikshetchikov1 < t:
	n = input()
	n = int(n)
	s = [int(i) for i in input().split()]
	shetchikshetchikov = 0
	while shetchikshetchikov < len(s):
		shetchik = shetchikshetchikov
		maksimum = shetchik
		while shetchik < len(s):
			if s[maksimum] > s[shetchik]:
				maksimum = shetchik
			shetchik = shetchik + 1
		(s[maksimum], s[shetchikshetchikov]) = (s[shetchikshetchikov], s[maksimum])
		shetchikshetchikov = shetchikshetchikov + 1
	shetchik123 = 0
	raznitsa = 0
	minimum = s[shetchik123 + 1] - s[shetchik123]
	while shetchik123 < n - 1:
		if minimum > s[shetchik123 + 1] - s[shetchik123]:
			minimum = s[shetchik123 + 1] - s[shetchik123]
		shetchik123 = shetchik123 + 1
	print(minimum)
	shetchikshetchikov1 = shetchikshetchikov1 + 1


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mi = 1000000000
	for i in range(n - 1):
		for j in range(i + 1, n):
			mi = min(mi, abs(arr[i] - arr[j]))
	print(mi)


import sys
T = int(input())

def ans(s):
	s = sorted(s)
	N = len(s)
	ans = float('inf')
	for i in range(N - 1):
		ans = min(ans, s[i + 1] - s[i])
	return ans
for t in range(T):
	input()
	s = input().split(' ')
	s = list((int(x) for x in s))
	print(ans(s))


def main():
	n = int(input())
	s = sorted(list(map(int, input().split())))
	s_d = [s[i] - s[i - 1] for i in range(1, n)]
	print(min(s_d))
for _ in range(int(input())):
	main()


n = int(input())
l1 = []
for i in range(n):
	v = int(input())
	l = list(map(int, input().split()))
	for j in range(v - 1):
		a = min(l)
		l.remove(a)
		b = min(l)
		l1.append(b - a)
	print(min(l1))
	l1.clear()


for _ in range(int(input())):
	n = int(input())
	score = list(map(int, input().split(' ')))
	score.sort()
	score2 = []
	for i in range(1, n):
		score2.append(abs(score[i] - score[i - 1]))
	mn = max(score2)
	for i in range(n - 1):
		if score2[i] < mn:
			mn = score2[i]
	index = score2.index(mn)
	print(abs(score[index] - score[index + 1]))


def task(n, s):
	s.sort()
	best = 1000000
	for i in range(1, len(s)):
		diff = abs(s[i - 1] - s[i])
		if diff < best:
			best = diff
	print(best)
t = int(input())
for i in range(0, t):
	n = int(input())
	s = list(map(int, input().split()))
	task(n, s)


n = int(input())
for i in range(n):
	z = int(input())
	l = list(map(int, input().split()))
	l.sort()
	result = l[z - 1] - l[0]
	for i in range(z):
		for j in range(i + 1, z):
			result = min(result, l[j] - l[i])
	print(result)


import math
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mini = 100001
	for i in range(1, len(l)):
		if mini > l[i] - l[i - 1]:
			mini = l[i] - l[i - 1]
	print(mini)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	flag = 1
	for i in range(n):
		if l.count(i) == 2:
			flag = 0
			print(0)
			break
	if flag == 0:
		continue
	m = abs(l[0] - l[1])
	for i in range(n - 1):
		for j in range(i + 1, n):
			if m > abs(l[i] - l[j]):
				m = abs(l[i] - l[j])
	print(m)


import math
t = int(input())
for i in range(t):
	n = int(input())
	lst = []
	lst += list(map(int, input().split()))
	lst.sort()
	min = math.inf
	for j in range(len(lst) - 1):
		if min > lst[j + 1] - lst[j]:
			min = lst[j + 1] - lst[j]
	print(min)


for _ in range(int(input())):
	n = int(input())
	s = map(int, input().split())
	s_sorted = sorted(s)
	min_diff = -1
	previous = -1
	for si in s_sorted:
		if previous == -1:
			previous = si
			continue
		diff = si - previous
		if min_diff == -1 or min_diff > diff:
			min_diff = diff
		previous = si
	print(min_diff)


from sys import stdin
input = stdin.readline
for Ti in range(int(input().strip())):
	n = int(input().strip())
	s = [int(x) for x in input().strip().split()]
	s.sort()
	d = float('inf')
	for i in range(1, len(s)):
		d = min(d, abs(s[i] - s[i - 1]))
	print(d)


def func(a):
	s = set()
	for i in range(len(a)):
		if a[i] not in s:
			s.add(a[i])
		else:
			return 0
	a.sort()
	diff = a[1] - a[0]
	for i in range(len(a) - 1):
		if diff > a[i + 1] - a[i]:
			diff = a[i + 1] - a[i]
	return diff
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(func(a))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	i = 1
	o = []
	while i < len(l):
		s = abs(l[i] - l[i - 1])
		o.append(s)
		i = i + 1
	o.sort()
	print(o[0])


n = int(input())
for iterations in range(n):
	l = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	x = 1
	min = 999
	while x < l:
		if arr[x] - arr[x - 1] < min:
			min = arr[x] - arr[x - 1]
		x += 1
	print(min)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	min_ = 1001
	for i in range(1, n):
		min_ = min(arr[i] - arr[i - 1], min_)
	print(min_)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	out = a[1] - a[0]
	for i in range(2, n):
		if a[i] - a[i - 1] < out:
			out = a[i] - a[i - 1]
	print(out)


import sys
input = lambda : sys.stdin.readline().strip()
inp = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	n = int(input())
	a = inp()
	a.sort()
	ans = float('inf')
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


import sys, bisect
input = sys.stdin.readline

def solve():
	n = int(input())
	al = list(map(int, input().split()))
	al.sort()
	ans = 10 ** 9
	for i in range(1, n):
		ans = min(abs(al[i - 1] - al[i]), ans)
	print(ans)

def main():
	t = int(input())
	for i in range(t):
		solve()
main()


for _ in range(int(input())):
	n = int(input())
	k = []
	A = list(map(int, input().split()))
	A.sort()
	for i in range(0, n - 1):
		k.append(A[i + 1] - A[i])
	print(min(k))


def solve():
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(set(arr1))
	arr2.sort()
	for i in arr2:
		if arr1.count(i) >= 2:
			return 0
	m = arr2[1] - arr2[0]
	for i in range(1, len(arr2)):
		m = min(m, arr2[i] - arr2[i - 1])
	return m
t = int(input())
while t:
	print(solve())
	t -= 1


def solve(n, arr):
	arr.sort()
	diff = 1000000000.0
	for i in range(0, n - 1):
		diff = min(diff, arr[i + 1] - arr[i])
	print(diff)
	return
t = int(input())
for i in range(0, t):
	n = int(input())
	arr = list(map(int, input().split()))
	solve(n, arr)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	minn = 1000
	for i in range(n - 1):
		k = s[i + 1] - s[i]
		minn = min(minn, k)
	print(minn)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s1 = l[0]
	l.sort()
	ans = 100000
	for i in range(1, n - 1):
		ans = min(ans, l[i] - l[i - 1])
	ans = min(ans, l[n - 1] - l[n - 2])
	print(ans)


t = int(input(''))
for i in range(t):
	n = int(input(''))
	s = list(map(int, input('').split(' ')))
	s.sort()
	s2 = s[1:]
	s2.append(s[0])
	s3 = [abs(s[i] - s2[i]) for i in range(len(s))]
	print(min(s3))


c = int(input())
for z in range(c):
	n = int(input())
	s = input()
	s = s.split()
	if n == 2:
		print(abs(int(s[0]) - int(s[1])))
	else:
		l = []
		for i in range(n - 1):
			for j in range(i + 1, n):
				a = abs(int(s[i]) - int(s[j]))
				l.append(a)
		print(min(l))


for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	b.sort()
	diff = []
	for i in range(len(b) - 1):
		diff.append(abs(b[i] - b[i + 1]))
	print(min(diff))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	d = 1005
	for i in range(len(a) - 1):
		d = min(d, a[i] - a[i + 1])
		if d == 0:
			break
	print(d)


for _ in range(int(input())):
	noa = int(input())
	athlates = list(map(int, input().split()))
	athlates.sort()
	result = []
	previous = athlates[0]
	for i in athlates[1:]:
		result.append(abs(previous - i))
		previous = i
	print(min(result))


t = int(input())
for u in range(t):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	ans = 10000
	for i in range(0, n - 1):
		ans = min(ans, s[i + 1] - s[i])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l, reverse=True)
	(a, b) = ([], [])
	min_d = 9999999999999999
	min_p = [0, 0]
	for i in range(n - 1):
		mini = abs(l[i] - l[i + 1])
		if mini < min_d:
			min_d = mini
			(min_p[0], min_p[1]) = (l[i], l[i + 1])
	for i in range(len(min_p)):
		l.remove(min_p[i])
	l = sorted(l)
	for e in l:
		if e <= max(min_p[0], min_p[1]):
			a.append(e)
		else:
			b.append(e)
	a.append(min(min_p[0], min_p[1]))
	b.append(max(min_p[0], min_p[1]))
	a = sorted(a)
	b = sorted(b)
	print(min_d)


def solve():
	n = input()
	players = list(map(int, input().split()))
	players.sort()
	print(min((y - x for (x, y) in zip(players, players[1:]))))
for _ in range(int(input())):
	solve()


def Sol(l):
	lst = sorted(l)
	return min([abs(i - j) for (i, j) in list(zip(lst, lst[1:]))])
T = int(input())
for i in range(T):
	n = int(input())
	li = list((int(x) for x in input().strip().split()))[:n]
	print(Sol(li))


from collections import Counter
n = int(input())
for i in range(n):
	k = int(input())
	numbers = list(map(int, input().split()))
	c = Counter(numbers)
	flag = True
	for i in c:
		if c[i] >= 2:
			flag = False
			print(0)
			break
	if flag:
		numbers.sort()
		largest = numbers[len(numbers) - 1]
		diff = []
		for i in range(0, len(numbers) - 1):
			diff.append(abs(numbers[i] - numbers[i + 1]))
		diff.sort()
		print(diff[0])


from sys import stdin
input = stdin.readline

def main():
	test = int(input())
	for t in range(test):
		n = int(input())
		l = [int(i) for i in input().split(' ')]
		l.sort()
		mini = l[-1]
		for i in range(n - 1):
			mini = min(l[i + 1] - l[i], mini)
		print(mini)
main()


t = int(input())

def findMinDiff(arr, n):
	arr = sorted(arr)
	diff = 10 ** 20
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < diff:
			diff = arr[i + 1] - arr[i]
	print(diff)
for _ in range(t):
	s = int(input())
	arr = list(map(int, input().split()))
	findMinDiff(arr, s)


t = int(input())
for x in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = []
	for x in range(1, n):
		d.append(l[x] - l[x - 1])
	print(min(d))


test = int(input())
while test > 0:
	n = int(input())
	l = list(map(int, input().split(' ')))
	l.sort()
	min_b = max(l)
	for i in range(1, n):
		min_b = min(min_b, abs(l[i] - l[i - 1]))
	print(min_b)
	test -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	arr = sorted([int(x) for x in input().split()])
	print(min([arr[x] - arr[x - 1] for x in range(1, n)]))


a = int(input())
for i in range(0, a):
	b = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	diff = []
	for i in range(1, len(arr)):
		diff.append(arr[i] - arr[i - 1])
	print(min(diff))


for i in range(int(input())):
	n = int(input())
	lis = [int(x) for x in input().split()]
	lis.sort()
	mindiff = 100000000
	for i in range(n - 1):
		mindiff = min(mindiff, abs(lis[i] - lis[i + 1]))
	print(mindiff)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	ss = 10000
	for i in range(1, n):
		if a[i] - a[i - 1] < ss:
			ss = a[i] - a[i - 1]
	print(ss)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mn = 10000000
	for i in range(n - 1):
		mn = min(mn, arr[i + 1] - arr[i])
	print(mn)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	l = sorted(l)
	if len(l) != len(s):
		print('0')
		continue
	m = 999
	for i in range(n - 1):
		if l[i + 1] - l[i] < m:
			m = l[i + 1] - l[i]
	print(m)


for ad in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	x = []
	for i in range(n - 1):
		x.append(l[i + 1] - l[i])
	print(min(x))


T = int(input())

def solve(array):
	array = sorted(array)
	if len(array) == 2:
		return array[1] - array[0]
	diff = float('inf')
	i = 0
	while i + 1 < len(array):
		temp_diff = array[i + 1] - array[i]
		if temp_diff < diff:
			diff = temp_diff
		i += 1
	return diff
out_li = []
for _ in range(T):
	N = int(input())
	array = list(map(int, input().split()))
	out_li.append(solve(array))
for num in out_li:
	print(num)


def Calcul(l):
	l.sort()
	differences = []
	for i in range(1, n):
		dif = l[i] - l[i - 1]
		differences.append(dif)
	return min(differences)
t = int(input())
output = []
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	output.append(Calcul(l))
for _ in output:
	print(_)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	ans = 1061109567
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


from sys import stdin

def readline():
	return stdin.readline()
tests = int(readline())

def solve(n, arr):
	minDiff = 1000
	for i in range(0, n):
		for j in range(i + 1, n):
			if minDiff > abs(arr[i] - arr[j]):
				minDiff = abs(arr[i] - arr[j])
	return minDiff
for t in range(0, tests):
	n = int(readline())
	arr = list(map(int, readline().split(' ')))
	print(solve(n, arr))


from sys import stdin, stdout

def II():
	return int(stdin.readline())

def LI():
	return list(map(int, stdin.readline().split()))
t = II()
for _ in range(t):
	n = II()
	s = LI()
	s.sort()
	ans = s[1] - s[0]
	for i in range(2, n):
		x = s[i] - s[i - 1]
		ans = min(ans, x)
	stdout.write(str(ans) + '\n')


for t in range(int(input())):
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	ans = 104206969
	for i in range(1, len(s)):
		ans = min(ans, abs(s[i] - s[i - 1]))
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	li = [int(x) for x in input().split()]
	li.sort()
	minm = 1000000
	for i in range(n - 1):
		k = abs(li[i + 1] - li[i])
		if k < minm:
			minm = k
	print(minm)
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	s = list(sorted(map(int, input().split())))
	d = s[n - 1] - s[0]
	for i in range(1, n):
		d = min(d, s[i] - s[i - 1])
	ind = 0
	for i in range(1, n):
		if s[i] - s[i - 1] == d:
			ind = i
			break
	print(d)


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	m = 10 ** 9
	for i in range(n - 1):
		m = min(m, a[i + 1] - a[i])
	print(m)


from collections import Counter
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	m = 1000
	for i in range(n - 1):
		var = abs(arr[i] - arr[i + 1])
		m = min(m, var)
	print(m)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	a.sort()
	M = 9999999999999999
	for i in range(n - 1):
		M = min(M, a[i + 1] - a[i])
	print(M)


t = int(input())
for i in range(t):
	n = int(input())
	a = []
	a = list(map(int, input().split()))
	a.sort()
	min = a[n - 1]
	for i in range(n - 1):
		if a[i + 1] - a[i] < min:
			min = a[i + 1] - a[i]
	print(min)


try:
	for _ in range(int(input())):
		n = int(input())
		arr = [int(i) for i in input().split()]
		anss = float('inf')
		arr.sort(reverse=True)
		for i in range(n - 1):
			if arr[i] - arr[i + 1] < anss:
				anss = arr[i] - arr[i + 1]
		print(anss)
except:
	pass


for _ in range(int(input())):
	n = int(input().strip())
	arr = list(map(int, input().strip().split()))
	arr = sorted(arr)
	mini = 10000000
	for i in range(1, n):
		if arr[i] - arr[i - 1] < mini:
			mini = arr[i] - arr[i - 1]
	print(mini)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	min = l[1] - l[0]
	for j in range(2, len(l)):
		d = l[j] - l[j - 1]
		if d < min:
			min = d
	print(min)


t = int(input())
for r in range(t):
	n = int(input())
	k = list(map(int, input().split()))
	A = [0] * (n - 1)
	k.sort()
	for i in range(n - 1):
		A[i] = abs(k[i] - k[i + 1])
	print(min(A))


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	minn = -1
	for j in range(-1, -len(s), -1):
		if s[j] - s[j - 1] < minn or minn == -1:
			minn = s[j] - s[j - 1]
	print(minn)


from sys import maxsize
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	if n == 2:
		print(a[1] - a[0])
	else:
		ans = maxsize
		for i in range(1, n):
			diff = a[i] - a[i - 1]
			if diff < ans:
				ans = diff
		print(ans)


t = int(input())
i = 1
while i <= t:
	n = int(input())
	list1 = list(map(int, input().split()))
	minn = 10000
	list1.sort()
	for j in range(n - 1):
		diff = list1[j + 1] - list1[j]
		minn = min(minn, diff)
	print(minn)
	i = i + 1


import math
import sys
import collections
from collections import defaultdict
sys.setrecursionlimit(10 ** 9)
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	min1 = sys.maxsize
	for i in range(1, n):
		min1 = min(arr[i] - arr[i - 1], min1)
	print(min1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b1 = [0 for _ in range(n - 1)]
	for i in range(n - 1):
		b1[i] = a[i + 1] - a[i]
	print(min(b1))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	mn = 500000
	for i in range(0, n - 1):
		mn = min(mn, ar[i + 1] - ar[i])
	print(mn)


klp = int(input())
for klpr in range(klp):
	n = int(input())
	s = [int(i) for i in input().split()]
	s.sort()
	mn = 1001
	for i in range(n - 1):
		r = s[i + 1] - s[i]
		mn = min(mn, r)
	print(mn)


import sys
file_name = ''
if file_name:
	f = open(file_name, 'r')
else:
	f = sys.stdin
line = f.readline()
q = int(line)
for _ in range(q):
	line = f.readline()
	n = int(line)
	line = f.readline()
	l = [int(x) for x in line.split()]
	l.sort()
	min = l[1] - l[0]
	for i in range(1, len(l) - 1):
		if l[i + 1] - l[i] < min:
			min = l[i + 1] - l[i]
	print(min)


q = int(input())
for i in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	wynik = 23472983749823739
	for i in range(1, n):
		wynik = min(wynik, l[i] - l[i - 1])
	print(wynik)


def linp():
	return list(map(int, input().split()))
for _ in range(int(input())):
	n = int(input())
	l = linp()
	l.sort()
	ans = 10 ** 18
	for i in range(1, n):
		ans = min(abs(l[i] - l[i - 1]), ans)
	print(ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 100000000
	for i in range(1, n):
		ans = min(ans, abs(l[i] - l[i - 1]))
	print(ans)


x = int(input())
for i in range(0, x):
	y = int(input())
	b = list(map(int, input().split()))
	b.sort()
	min1 = 999999999
	for i in range(0, len(b) - 1):
		diff = b[i + 1] - b[i]
		if diff < min1:
			min1 = diff
		else:
			continue
	print(min1)


t = int(input())
for _ in range(t):
	n = input()
	s = [int(k) for k in input().split()]
	s.sort()
	m = 99999999999
	for i in range(1, len(s)):
		diff = abs(s[i] - s[i - 1])
		m = min(diff, m)
	print(m)


amount = int(input())
allSets = []
res = []
for i in range(amount):
	s = int(input())
	Set = list(map(int, input().split()))
	Set.sort()
	m = abs(Set[0] - Set[s - 1])
	for j in range(s - 1):
		Shift = abs(Set[j] - Set[j + 1])
		if Shift < m:
			m = Shift
	res.append(m)
for e in res:
	print(e)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split(' ')))
	l = sorted(l)
	sumi = 0
	mini = l[1] - l[0]
	for i in range(len(l) - 1):
		if mini > l[i + 1] - l[i]:
			mini = l[i + 1] - l[i]
			if mini == 0:
				break
	print(mini)


for _ in range(int(input())):
	n = int(input())
	s = [int(x) for x in input().split()]
	if n == 2:
		print(abs(s[0] - s[1]))
	else:
		s_sort = sorted(s)
		min_d = max(s)
		prev = s_sort[0]
		for i in range(1, n):
			cur = s_sort[i] - prev
			if cur < min_d:
				min_d = cur
			if min_d == 0:
				break
			prev = s_sort[i]
		print(min_d)


for _ in ' ' * int(input()):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	l1 = [abs(l[i] - l[i + 1]) for i in range(n - 1)]
	print(min(l1))


import sys
INT_MAX = sys.maxsize
INT_MIN = -sys.maxsize - 1
mod = 1000000007

def solve():
	t = int(sys.stdin.readline())
	for _ in range(t):
		n = int(sys.stdin.readline())
		a = list(map(int, sys.stdin.readline().split()))
		a.sort()
		maxx = INT_MAX
		for i in range(1, n):
			maxx = min(maxx, a[i] - a[i - 1])
		print(maxx)
solve()


tes = int(input())
while tes != 0:
	n1 = int(input())
	v = list(map(int, input().split()))
	v.sort()
	valu = 10000000
	for i in range(1, n1):
		f = abs(v[i] - v[i - 1])
		if f < valu:
			valu = f
	print(valu)
	tes -= 1


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	b = 10000
	for i in range(1, n):
		if a[i] - a[i - 1] < b:
			b = a[i] - a[i - 1]
	print(b)


t = int(input())
while t != 0:
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	for i in range(0, n - 1):
		temp = lst[i + 1] - lst[i]
		if i == 0:
			res = temp
		elif res > temp:
			res = temp
		elif res == 0:
			break
	print(res)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	if n == 2:
		print(abs(s[0] - s[1]))
	else:
		s.sort()
		mi = 9999999999
		for j in range(1, n):
			if s[j] - s[j - 1] < mi:
				mi = s[j] - s[j - 1]
		print(mi)


for _ in range(int(input())):
	n = int(input())
	a = sorted([int(i) for i in input().split()])
	min = max(a)
	for i in range(n - 1):
		if a[i + 1] - a[i] < min:
			min = a[i + 1] - a[i]
	print(min)


import sys
T = int(input())
for _ in range(T):
	n = int(input())
	l = list(map(int, input().split()))
	m = sys.maxsize
	for i in range(n):
		for j in range(i + 1, n):
			m = min(m, abs(l[i] - l[j]))
	print(m)


for i in range(int(input())):
	x = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	mini = 100000000
	for i in range(1, x):
		mini = min(mini, lst[i] - lst[i - 1])
	print(mini)


for _ in range(int(input())):
	N = int(input())
	arr = [int(x) for x in input().split()]
	arr = sorted(arr)
	diff = arr[1] - arr[0]
	for i in range(N - 1):
		val = arr[i + 1] - arr[i]
		if val < diff:
			diff = val
	print(diff)


t = int(input())
for i in range(t):
	n = int(input())
	s = []
	s = list(map(int, input().split()))
	s.sort()
	k = 1001
	for j in range(n - 1):
		if s[j + 1] - s[j] < k:
			k = s[j + 1] - s[j]
	print(k)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	pr = 10 ** 9
	for i in range(n - 1):
		d = l[i + 1] - l[i]
		if d <= pr:
			pr = d
	print(pr)


for i in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	m = lst[1] - lst[0]
	for j in range(2, n):
		if lst[j] - lst[j - 1] < m:
			m = lst[j] - lst[j - 1]
	print(m)


for t in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	diff = float('inf')
	for i in range(n - 1):
		if s[i + 1] - s[i] < diff:
			diff = s[i + 1] - s[i]
	print(diff)


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	min = 10 ** 9
	for i in range(len(a) - 1):
		if a[i + 1] - a[i] < min:
			min = a[i + 1] - a[i]
	ans.append(min)
for i in ans:
	print(i)


T = int(input())
for _ in range(0, T):
	N = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	s = s[::-1]
	ans = s[0] - s[1]
	for i in range(1, len(s) - 1):
		ans = min(ans, s[i] - s[i + 1])
	print(ans)


for g in range(int(input())):
	diff = 10000000
	n = input()
	s = [int(h) for h in input().split()]
	s.sort()
	for i in range(len(s) - 1):
		for j in range(i + 1, len(s)):
			if abs(s[i] - s[j]) < diff:
				diff = abs(s[i] - s[j])
	print(diff)


def main():
	t = int(input())
	ans = []
	for i in range(t):
		n = int(input())
		arr = list(map(int, input().split()))
		arr.sort()
		min_val = float('inf')
		for i in range(n - 1):
			min_val = min(min_val, arr[i + 1] - arr[i])
		ans.append(min_val)
	for i in ans:
		print(i)
main()


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	n = I()
	a = li()
	a.sort()
	d = a[1] - a[0]
	for i in range(1, n - 1):
		d = min(d, a[i + 1] - a[i])
	print(d)
for _ in range(I()):
	solve()


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		s = list(map(int, input().split()))
		s.sort()
		mini = float('inf')
		for i in range(n):
			if i + 1 < n:
				if abs(s[i] - s[i + 1]) < mini:
					mini = abs(s[i] - s[i + 1])
		print(mini)
main()


def answer():
	n = int(input())
	c_out = []
	while n:
		l = int(input())
		t = input().split()
		t = [int(x) for x in t]
		t.sort()
		i = 0
		k = []
		while i < len(t) - 1:
			k.append(abs(t[i] - t[i + 1]))
			i += 1
		c_out.append(min(k))
		n -= 1
	for x in c_out:
		print(x)
answer()


tests = int(input())
for t in range(tests):
	n = input()
	stren = input()
	use = [int(x) for x in stren.split()]
	use.sort()
	minim = 31048577205837
	for i in range(len(use) - 1):
		temp = abs(use[i] - use[i + 1])
		if temp < minim:
			minim = temp
	print(minim)


t = int(input())
for k in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	val = 100000
	for i in range(n - 1, 0, -1):
		temp = abs(l[i] - l[i - 1])
		if temp < val:
			val = temp
	print(val)


import sys
input = sys.stdin.buffer.readline

def solution():
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, input().split()))
		l.sort()
		m = 2000000000.0
		for i in range(1, n):
			m = min(m, l[i] - l[i - 1])
		print(m)
solution()


def scanInt():
	return int(input())

def scanList():
	return input().split(' ')

def scanIntList():
	return [int(i) for i in scanList()]
t = int(input())
for _ in range(t):
	n = scanInt()
	a = scanIntList()
	a.sort()
	ans = int(1000000000.0)
	for i in range(len(a) - 1):
		ans = min(ans, a[i + 1] - a[i])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = 100000
	for i in range(1, n):
		x = l[i] - l[i - 1]
		if x < m:
			m = x
	print(m)


for _ in range(int(input())):
	n = int(input())
	lst = [int(i) for i in input().split()]
	lst.sort(reverse=True)
	mi = max(lst) + 1
	for i in range(n - 1):
		if lst[i] - lst[i + 1] <= mi:
			mi = lst[i] - lst[i + 1]
	print(mi)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s = sorted(s)
	res = 999
	for i in range(len(s) - 1):
		if res > abs(s[i + 1] - s[i]):
			res = abs(s[i + 1] - s[i])
	print(res)


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort()
	m = 10 ** 9 + 7
	for i in range(1, n):
		m = min(m, lis[i] - lis[i - 1])
	print(m)


def returnMin(lst):
	lst = sorted(lst)
	return min([abs(a - b) for (a, b) in list(zip(lst, lst[1:]))])
n = int(input())
for i in range(n):
	size = int(input())
	l = list((int(x) for x in input().strip().split()))[:size]
	print(returnMin(l))


from math import inf

def func(n, arr):
	arr.sort()
	minm = inf
	for i in range(1, n):
		if arr[i] - arr[i - 1] < minm:
			minm = arr[i] - arr[i - 1]
	print(minm)
	return
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	func(n, arr)


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	ans = 100000
	for i in range(n - 1):
		ans = min(ans, abs(lst[i + 1] - lst[i]))
	print(ans)


import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def solve():
	n = int(input())
	arr = list_input()
	arr.sort()
	ans = 10 ** 10
	for i in range(n - 1):
		ans = min(ans, arr[i + 1] - arr[i])
	print(ans)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	ans = 999999999999
	for i in range(1, n):
		p = lst[i] - lst[i - 1]
		if p < ans:
			ans = p
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	s1 = input()
	s1 = s1.split(' ')
	mapobj = map(int, s1)
	s = list(mapobj)
	s.sort()
	em = []
	for j in range(len(s)):
		if j == len(s) - 1:
			break
		else:
			temp = int(s[j]) - int(s[j + 1])
			if temp < 0:
				temp = -temp
				em.append(temp)
			else:
				em.append(temp)
	print(min(em))


import queue
import math
t = int(input())
while t:
	n = int(input())
	a = input().split()
	a = [int(x) for x in a]
	a.sort()
	minD = a[1] - a[0]
	for i in range(1, n - 1):
		minD = min(minD, a[i + 1] - a[i])
	print(minD)
	t -= 1


t = int(input())
i = 0
for h in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	s.reverse()
	j = 0
	k = []
	while j < n - 1:
		k.append(s[j] - s[j + 1])
		j += 1
	k.sort()
	print(k.pop(0))


for _ in range(int(input())):
	n = int(input())
	ath = sorted(list(map(int, input().split())))
	best = ath[-1] - ath[0]
	for i in range(1, n):
		best = min(best, ath[i] - ath[i - 1])
	print(best)


t = int(input())
while t > 0:
	n = int(input())
	x = [int(x) for x in input().split()]
	x.sort()
	diff = x[1] - x[0]
	for i in range(1, n):
		if x[i] - x[i - 1] < diff:
			diff = x[i] - x[i - 1]
	print(diff)
	t -= 1


def driver():
	t = int(input())
	for i in range(t):
		print(solution())

def solution():
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	interval = a[1] - a[0]
	for i in range(1, n - 1):
		temp = a[i + 1] - a[i]
		if interval > temp:
			interval = temp
			if interval == 0:
				return interval
	return interval
driver()


n = int(input())
for _ in range(n):
	input()
	a = list(map(int, input().split()))
	a = sorted(a)
	prev = a[0]
	m = abs(a[1] - a[0])
	for i in range(2, len(a)):
		m = min(abs(a[i] - a[i - 1]), m)
	print(m)


def main():
	for _ in range(int(input())):
		n = int(input())
		lst = list(map(int, input().split()))
		lst = sorted(lst)
		mn = 100000
		for i in range(len(lst) - 1):
			if lst[i + 1] - lst[i] < mn:
				mn = lst[i + 1] - lst[i]
		print(mn)
main()


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	mini = 999999999999999
	for j in range(n - 1):
		if arr[j + 1] - arr[j] < mini:
			mini = arr[j + 1] - arr[j]
	print(mini)


n = int(input())
for _ in range(n):
	res = []
	t = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	for i in range(1, len(arr)):
		diff = arr[i] - arr[i - 1]
		res.append(diff)
	res.sort()
	print(res[0])


def nod(a, b):
	while a != b:
		(a, b) = (max(a, b), min(a, b))
		if a % b == 0:
			a -= (a // b - 1) * b
		else:
			a -= a // b * b
	return a
for t in range(int(input())):
	n = int(input())
	a = list(sorted([int(x) for x in input().split()]))
	m = a[1] - a[0]
	for i in range(1, n):
		m = min(a[i] - a[i - 1], m)
	print(m)


z = int(input())
for x in range(z):
	n = int(input())
	l = list(map(int, input().split()))
	min = abs(l[0] - l[1])
	for i in range(0, n - 1):
		for j in range(i + 1, n):
			if l[i] == l[j]:
				min = 0
			elif min > abs(l[i] - l[j]):
				min = abs(l[i] - l[j])
	print(min)


for _ in range(int(input())):
	n = int(input())
	a = map(int, input().split())
	a = sorted(a)
	l = 0
	h = n - 1
	ans = float('inf')
	for i in range(n - 1):
		ans = min(ans, abs(a[i] - a[i + 1]))
	for i in range(1, n):
		ans = min(ans, abs(a[0] - a[i]))
	for i in range(0, n - 1):
		ans = min(ans, abs(a[i] - a[n - 1]))
	print(ans)


from collections import Counter
from collections import defaultdict
from collections import deque
import math
import heapq
import sys
input = sys.stdin.readline
import bisect
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rls = lambda : list(map(str, input().split()))
t = int(input())
for _ in range(0, t):
	n = int(input())
	a = rl()
	a.sort()
	ans = float('inf')
	for i in range(0, n - 1):
		ans = min(a[i + 1] - a[i], ans)
	print(ans)


f = []
for i in range(int(input())):
	t = int(input())
	p = list(map(int, input().split()))
	p.sort()
	res = 100000000000
	for i in range(len(p) - 1):
		res = min(res, abs(p[i] - p[i + 1]))
	f.append(res)
for i in range(len(f)):
	print(f[i])


t = int(input())
count = 0
result = []
while count < t:
	l = int(input())
	n = input().split()
	n = [int(x) for x in n]
	n = sorted(n)
	all_p = []
	for x in range(0, l - 1):
		re = abs(n[x] - n[x + 1])
		all_p.append(re)
	all_p = sorted(all_p)
	result.append(all_p[0])
	count += 1
for x in result:
	print(x)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	ans = l[1] - l[0]
	for i in range(2, n):
		d = l[i] - l[i - 1]
		if d < ans:
			ans = d
	print(ans)


def solve(n, S):
	S = sorted(S)
	return min((S[i + 1] - S[i] for i in range(0, n - 1)))

def main():
	T = int(input())
	for _ in range(T):
		n = int(input())
		S = list(map(int, input().split()))
		print(solve(n, S))
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(s) for s in input().split()]
	a.sort()
	d = a[1] - a[0]
	for j in range(n - 1):
		if a[j + 1] - a[j] < d:
			d = a[j + 1] - a[j]
		if d == 0:
			break
	print(d)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort(reverse=False)
	b = []
	for i in range(n - 1):
		c = abs(s[i] - s[i + 1])
		b.append(c)
	print(min(b))


for _ in range(int(input())):
	input()
	a = sorted(map(int, input().split()))
	print(min((y - x for (x, y) in zip(a, a[1:]))))


import math

def HonestCoach(arr, n):
	arr.sort()
	return min((abs(arr[i] - arr[i + 1]) for i in range(n - 1)))
test = int(input())
for t in range(test):
	n = int(input())
	arr = [int(j) for j in input().split()]
	result = HonestCoach(arr, len(arr))
	print(result)


import sys
lines = sys.stdin.readlines()
T = int(lines[0].strip())
for t in range(T):
	n = int(lines[2 * t + 1].strip())
	nums = list(map(int, lines[2 * t + 2].strip().split(' ')))
	nums.sort()
	mini = nums[-1] - nums[0]
	for i in range(1, n):
		mini = min(nums[i] - nums[i - 1], mini)
	print(mini)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	items = []
	for i in range(1, n):
		x = a[i] - a[i - 1]
		items.append(x)
	print(min(items))


def solve():
	n = int(input())
	strenghts = sorted([int(x) for x in input().split()])
	return min((abs(strenghts[i] - strenghts[i + 1]) for i in range(len(strenghts) - 1)))
T = int(input())
for case in range(T):
	print(solve())


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	ans = [abs(l[j] - l[j - 1]) for j in range(n)]
	print(min(ans))


import itertools
n = int(input())
for _ in range(n):
	arr = []
	t = int(input())
	a = list(map(int, input().split()))
	for (n1, n2) in list(itertools.combinations(a, 2)):
		arr.append(abs(n1 - n2))
	print(min(arr))


for t in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	a = [0] * (max(s) + 1)
	for i in s:
		a[i] += 1
	ans = 1
	for i in a:
		if i >= 2:
			ans = 0
			break
	if ans == 0:
		print(0)
	else:
		s.sort()
		mi = 10 ** 10
		for i in range(1, n):
			mi = min(mi, s[i] - s[i - 1])
		print(mi)


t = int(input()) * 2
arr = []
for _ in range(t):
	arr.append(list(map(int, input().split())))
for i in range(0, t - 1, 2):
	n = arr[i][0]
	i += 1
	ar = sorted(arr[i])
	L = []
	for i in range(len(ar) - 1):
		L.append(ar[i + 1] - ar[i])
	print(sorted(L)[0])


import math
t = int(input())
for _ in range(t):
	n = int(input())
	athletes = list(map(int, input().split()))
	athletes.sort()
	min_diff = math.inf
	for i in range(n - 1):
		min_diff = min(min_diff, athletes[i + 1] - athletes[i])
	print(min_diff)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().split()
	for j in range(n):
		s[j] = int(s[j])
	s.sort()
	l = []
	for j in range(n - 1):
		if s[j + 1] >= s[j]:
			l.append(s[j + 1] - s[j])
		else:
			l.append(s[j] - s[j + 1])
	print(min(l))


t = int(input())
for i in range(t):
	n = int(input())
	ll = list(map(int, input().split()))
	ll = sorted(ll)
	s = 10000000
	for j in range(len(ll) - 1):
		s = min(s, abs(ll[j] - ll[j + 1]))
	print(s)


def solve(A, n):
	A = sorted(A)
	diff = float('inf')
	for i in range(1, len(A)):
		diff = min(diff, A[i] - A[i - 1])
	return diff
res = []
t = int(input())
while t:
	n = int(input())
	arr = input().split(' ')
	A = [int(n) for n in arr]
	res.append(solve(A, n))
	t -= 1
for r in res:
	print(r)


t = int(input())
for i in range(t):
	n = int(input())
	array = sorted(map(int, input().split()))
	min_value = float('inf')
	for k in range(1, n):
		if array[k] - array[k - 1] < min_value:
			min_value = array[k] - array[k - 1]
			if min_value == 0:
				print(0)
				break
	else:
		print(min_value)


def ans(arr):
	arr.sort()
	diff = max(arr)
	for i in range(1, n):
		if diff > arr[i] - arr[i - 1]:
			diff = arr[i] - arr[i - 1]
	return diff
m = int(input())
for i in range(m):
	n = int(input())
	a = input().split()
	arr = []
	for i in range(n):
		arr.append(int(a[i]))
	print(ans(arr))


from sys import stdin, stdout
from collections import Counter
t = int(input())
for _ in range(t):
	n = int(stdin.readline())
	s = list(map(int, stdin.readline().strip().split()))
	s.sort()
	c = Counter(s)
	if c.most_common()[0][1] > 1:
		print(0)
	else:
		ans = 10 ** 9
		for i in range(n - 1):
			if ans > s[i + 1] - s[i]:
				ans = s[i + 1] - s[i]
		print(ans)


import sys
input = sys.stdin.readline
(t,) = map(int, input().split())
for _ in range(t):
	(N,) = map(int, input().split())
	X = sorted(list(map(int, input().split())))
	r = 10 ** 18
	for i in range(N - 1):
		r = min(r, X[i + 1] - X[i])
	print(r)


t = int(input())
for tt in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	m = s[-1]
	for i in range(0, len(s) - 1):
		if m > s[i + 1] - s[i]:
			m = s[i + 1] - s[i]
	print(m)


for i in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split(maxsplit=n)))
	lst.sort()
	temp = []
	for i in range(1, len(lst)):
		temp.append(lst[i] - lst[i - 1])
	print(min(temp))


T = int(input())
for t in range(T):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	m = float('inf')
	for i in range(1, n):
		m = min(m, abs(s[i] - s[i - 1]))
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	mn = float('inf')
	arr.sort()
	for i in range(n - 1):
		mn = min(mn, arr[i + 1] - arr[i])
	print(mn)


t = int(input())
while t > 0:
	n = int(input())
	mn = int(999999999999999999999)
	i = 0
	lst = list(map(int, input().split()))
	lst.sort()
	if n == 2:
		print(abs(lst[0] - lst[1]))
	else:
		for i in range(n - 1):
			d = abs(lst[i] - lst[i + 1])
			if d <= mn:
				mn = abs(lst[i] - lst[i + 1])
		print(mn)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	inp = list(map(int, input().split()))
	inp.sort()
	ans = 99999999999
	for i in range(1, len(inp)):
		if inp[i] - inp[i - 1] < ans:
			ans = inp[i] - inp[i - 1]
	print(ans)


for _ in range(int(input())):
	n = int(input())
	data = list(map(int, input().split()))
	data.sort()
	answer = data[n - 1] - data[0]
	for i in range(n - 1):
		answer = min(data[i + 1] - data[i], answer)
	print(answer)


from pprint import pprint
import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	n = int(input())
	dat = list(map(int, input().split()))
	a = 0
	b = 0
	dat.sort()
	res = 9999999999999999999999999999
	for i in range(n - 1):
		res = min(res, dat[i + 1] - dat[i])
	print(res)


from math import *
n = int(input())
for i in range(n):
	m = int(input())
	tup = tuple(map(int, input().split()[:m]))
	tup = sorted(tup)
	min = tup[1] - tup[0]
	for i in range(1, len(tup)):
		if min > tup[i] - tup[i - 1]:
			min = tup[i] - tup[i - 1]
	print(min)


t = int(input())
i = 0
while i < t:
	n = int(input())
	s = [int(si) for si in input().split()]
	s.sort()
	minimal = float('inf')
	j = 0
	while j < n - 1:
		minimal = min(minimal, abs(s[j] - s[j + 1]))
		j += 1
	print(minimal)
	i += 1


import io
import os
import functools
import itertools
import math
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = sorted([int(x) for x in input().split()])
	answer = 10 ** 10
	for i in range(1, len(a)):
		answer = min(answer, a[i] - a[i - 1])
	print(answer)


t = int(input())
for i in range(t):
	n = int(input())
	s = [int(j) for j in input().split()]
	s.sort()
	d = [s[k + 1] - s[k] for k in range(n - 1)]
	print(min(d))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	m = max(s)
	for i in range(n - 1):
		if s[i + 1] - s[i] < m:
			m = abs(s[i + 1] - s[i])
	print(m)


for t in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	diff = max(li)
	for i in range(n - 1):
		if diff > li[i + 1] - li[i]:
			diff = li[i + 1] - li[i]
	print(diff)


a = int(input())
for i in range(a):
	s = int(input())
	z = list(map(int, input().split()))
	z.sort()
	ans = []
	for i in range(1, len(z)):
		ans.append(z[i] - z[i - 1])
	print(min(ans))


n = int(input())
(size, s) = ([], [])
for i in range(n):
	k = int(input())
	size.append(k)
	l = list(map(int, input().split()))
	s.append(l)

def coach(n, l):
	d = []
	for i in range(0, n):
		for j in range(i + 1, n):
			d.append(abs(l[j] - l[i]))
	return min(d)
for i in range(n):
	print(coach(size[i], s[i]))


import sys
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	ans = sys.maxsize
	for i in range(1, n):
		ans = min(ans, l[i] - l[i - 1])
	print(ans)


def solve():
	t = int(input())
	for i in range(t):
		n = int(input())
		m = sorted([int(s) for s in input().split()])
		ans = float('inf')
		for j in range(1, n):
			r = m[j] - m[j - 1]
			if r < ans:
				ans = r
		print(ans)
solve()


from math import *
from copy import *
from heapq import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(l):
	n = len(l)
	l.sort()
	minn = maxsize
	for i in range(1, n):
		minn = min(minn, l[i] - l[i - 1])
	return minn
T = int(input())
for _ in range(T):
	N = int(stdin.readline())
	l = list(map(int, stdin.readline().rstrip().split()))
	print(solve(l))


n = int(input())
for i in range(n):
	value = int(input())
	li = [int(x) for x in input().split()]
	li.sort()
	diff = 9999
	for i in range(1, len(li)):
		diff = min(diff, li[i] - li[i - 1])
	print(diff)


for _ in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	nums = sorted(nums)
	ans = 1001
	for i in range(n - 1):
		ans = min(ans, abs(nums[i + 1] - nums[i]))
	print(ans)


t = int(input())
for x in range(t):
	N = int(input())
	n = list(map(int, input().split()))
	n.sort(reverse=True)
	diff = abs(n[0] - n[1])
	for x in range(1, N - 1):
		if abs(n[x] - n[x + 1]) < diff:
			diff = n[x] - n[x + 1]
	print(diff)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	b = sorted(list(map(int, input().split())))
	m = 10000000000
	j = 0
	while j < n - 1:
		m = min(m, b[j + 1] - b[j])
		j += 1
	print(m)


t = int(input())
for te in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	a.sort()
	if n == 1:
		print(0)
		continue
	mini = 999999
	for i in range(1, n):
		mini = min(mini, a[i] - a[i - 1])
	print(mini)


t = int(input())
while t:
	n = int(input())
	lst = list(map(int, input().rstrip().split()))
	lst = sorted(lst)
	min = lst[1] - lst[0]
	for i in range(len(lst) - 1, 0, -1):
		diff = lst[i] - lst[i - 1]
		if diff < min:
			min = diff
	print(min)
	t -= 1


def f(b):
	b.sort()
	c = []
	for i in range(1, len(b)):
		c.append(abs(b[i] - b[i - 1]))
	c.sort()
	return c[0]
n = int(input())
for i in range(0, n):
	x = int(input())
	la = list(map(int, input().split(' ')[:n]))
	print(f(la))


t = int(input(''))
for test in range(t):
	n = int(input(''))
	pwr = input('')
	pwr_lst = [int(i) for i in pwr.split()]
	pwr_lst.sort()
	min_dif = None
	for i in range(len(pwr_lst) - 1):
		pwr_dif = pwr_lst[i + 1] - pwr_lst[i]
		if i == 0:
			min_dif = pwr_dif
		if pwr_dif == 0:
			min_dif = 0
			break
		elif pwr_dif < min_dif:
			min_dif = pwr_dif
	print(min_dif)


for _ in range(int(input())):
	n = int(input())
	s = sorted(map(int, input().split()))
	m = 1111
	for i in range(n - 1):
		if s[i + 1] - s[i] < m:
			m = s[i + 1] - s[i]
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	ls = [int(i) for i in input().split()]
	ls.sort()
	print(min([ls[i] - ls[i - 1] for i in range(1, len(ls))]))


t = int(input())
for _ in range(t):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	ans = float('INF')
	for i in range(n - 1):
		ans = min(ans, l[i + 1] - l[i])
	print(ans)


import math
q = int(input())
while q:
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	minDiff = 10000
	for i in range(0, len(arr) - 1):
		minDiff = min(abs(arr[i] - arr[i + 1]), minDiff)
	print(minDiff)
	q -= 1


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	a = max(s)
	b = min(s)
	for i in range(len(s) - 1):
		if abs(a - b) > abs(s[i] - s[i + 1]):
			a = s[i]
			b = s[i + 1]
	print(abs(a - b))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ms = None
	for i in range(1, n):
		c = a[i] - a[i - 1]
		if ms == None or ms > c:
			ms = c
	print(ms)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = [l[i + 1] - l[i] for i in range(len(l) - 1)]
	print(min(a))


import math

def main():
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	min_ = math.inf
	for i in range(1, n):
		min_ = min(min_, a[i] - a[i - 1])
	return min_
t = int(input())
while t > 0:
	t -= 1
	ans = main()
	print(ans)


t = int(input())
for x in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	mindiff = 1001
	for i in range(n - 1):
		if s[i + 1] - s[i] < mindiff:
			mindiff = s[i + 1] - s[i]
		if mindiff == 0:
			break
	print(mindiff)


import sys, math, cmath, time
start_time = time.time()
global tt

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def solve():
	n = inp()
	a = inlt()
	a.sort()
	q = [a[i + 1] - a[i] for i in range(len(a) - 1)]
	print(min(q))

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
	sys.stdout.close()

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


a = int(input())
for i in range(0, a):
	b = int(input())
	c = list(map(int, input().split()))
	c.sort()
	mn = 99999999999
	for j in range(b - 1):
		k = c[j + 1] - c[j]
		if k < mn:
			mn = k
	print(mn)


from sys import stdin, exit, setrecursionlimit
from collections import deque
from heapq import _heappop_max, heappush, heappop
from math import gcd
from math import ceil, log2
setrecursionlimit(10000000)
from collections import deque
input = stdin.readline
lmi = lambda : list(map(int, input().split()))
mi = lambda : map(int, input().split())
si = lambda : input().strip('\n')
ssi = lambda : input().strip('\n').split()
for _ in range(int(input())):
	n = int(input())
	a = lmi()
	a.sort()
	ans = float('inf')
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


for test_case in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 1000000000
	for i in range(n - 1):
		ans = min(ans, abs(a[i + 1] - a[i]))
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	lst = input().split()
	for i in range(n):
		lst[i] = int(lst[i])
	lst.sort()
	mn = None
	for i in range(n - 1):
		if mn == None:
			mn = lst[i + 1] - lst[i]
		else:
			diff = lst[i + 1] - lst[i]
			if diff < mn:
				mn = diff
	print(mn)


for i in range(int(input())):
	n = int(input())
	lis = [int(r) for r in input().split()]
	lis.sort()
	k = 1000000
	for r in range(n - 1):
		k = min(lis[r + 1] - lis[r], k)
	print(k)


t = int(input())
p = 0
while p < t:
	n = int(input())
	s = input().split()
	s.sort(key=int)
	p = p + 1
	b = 1
	f = int(s[0])
	min = int(s[len(s) - 1])
	while b < len(s):
		k = int(s[b])
		if k - f < min:
			min = k - f
		f = k
		b = b + 1
	print(min)


t = int(input())
for gf in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	m = a[1] - a[0]
	for i in range(1, n):
		m = min(a[i] - a[i - 1], m)
	print(m)


for i in range(int(input())):
	t = int(input())
	l = list(map(int, input().split()))
	l.sort()
	p = []
	for i in range(1, len(l)):
		p.append(l[i] - l[i - 1])
	print(min(p))


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	m = 2147483647
	for i in range(n - 1, 0, -1):
		m = min(m, a[i] - a[i - 1])
	print(m)


def fun(n, a):
	a = sorted(a)
	res = a[1] - a[0]
	for i in range(n - 1):
		res = min(res, a[i + 1] - a[i])
	return res
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	print(fun(n, a))


t = int(input())
for i in range(t):
	n = int(input())
	S = list(map(int, input().split()))
	S.sort()
	c = S[-1]
	for j in range(len(S) - 1):
		if abs(S[j] - S[j + 1]) <= c:
			c = abs(S[j] - S[j + 1])
	print(c)


x = int(input())
for _ in range(x):
	num_of_athletes = int(input())
	athletes_strengths = list(map(int, input().split()))
	athletes_strengths.sort()
	min_diff = athletes_strengths[1] - athletes_strengths[0]
	for i in range(num_of_athletes - 1):
		diff = abs(athletes_strengths[i] - athletes_strengths[i + 1])
		if diff < min_diff:
			min_diff = diff
	print(min_diff)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	count = 0
	lis = []
	for i in range(1, n):
		count = arr[i] - arr[i - 1]
		lis.append(count)
	lis.sort()
	print(lis[0])


def smallest_diff(arr):
	arr.sort()
	min_diff = float('inf')
	for i in range(1, len(arr)):
		if arr[i] - arr[i - 1] < min_diff:
			min_diff = arr[i] - arr[i - 1]
	return min_diff
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(smallest_diff(arr))


import sys
n = int(input())
for i in range(n):
	mx = sys.maxsize
	t = int(input())
	arr = list(map(int, input().split(' ')))
	arr = sorted(arr)
	for j in range(len(arr) - 1):
		mx = min(mx, abs(arr[j] - arr[j + 1]))
	print(mx)


for x in range(int(input())):
	v = int(input())
	l = list(map(int, input().split()))
	l.sort()
	b = l[0]
	mini = 10 ** 5
	for y in range(1, len(l)):
		if l[y] - b < mini:
			mini = l[y] - b
		b = l[y]
	print(mini)


import sys
t = int(input())
for tc in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = sys.maxsize
	for i in range(1, n):
		ans = min(ans, abs(s[i] - s[i - 1]))
	print(ans)


for _ in range(int(input())):
	n = int(input())
	strength = list(map(int, input().split(' ')))
	l = []
	for i in range(len(strength)):
		for j in range(len(strength)):
			if i != j:
				l.append(abs(strength[j] - strength[i]))
	print(min(l))


tc = int(input())
while tc > 0:
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = 2000
	for i in range(1, n):
		ans = min(abs(s[i] - s[i - 1]), ans)
		if ans == 0:
			break
	print(ans)
	tc -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	f = True
	minval = a[-1]
	for i in range(1, len(a)):
		if a[i] - a[i - 1] < minval:
			minval = a[i] - a[i - 1]
	print(minval)


def findMinDiff():
	n = int(input())
	arr = [int(i) for i in input().split()]
	diff = 10 ** 20
	for i in range(n - 1):
		for j in range(i + 1, n):
			if abs(arr[i] - arr[j]) < diff:
				diff = abs(arr[i] - arr[j])
	return diff
count = int(input())
result = []
for i in range(count):
	result.append(findMinDiff())
print(*result, sep='\n')


import math
for q in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	dif = 10 ** 15
	for i in range(n - 1):
		for j in range(i + 1, n):
			dif = min(dif, math.fabs(arr[i] - arr[j]))
	print(int(dif))


t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	current = max(s)
	for i in range(1, n):
		current = min(current, s[i] - s[i - 1])
	print(current)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort(reverse=True)
	ans = 999999999999
	for i in range(n - 1):
		if s[i] - s[i + 1] < ans:
			ans = s[i] - s[i + 1]
	print(ans)


try:
	for _ in range(int(input())):
		n = int(input())
		at = [int(i) for i in input().split()]
		ans = float('inf')
		at.sort(reverse=True)
		for i in range(n - 1):
			if at[i] - at[i + 1] < ans:
				ans = at[i] - at[i + 1]
		print(ans)
except:
	pass


t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	mi = 193743958437
	for i in range(n - 1):
		mi = min(mi, ar[i + 1] - ar[i])
	print(mi)


inp = input
li = list
iinp = lambda : int(inp())
ent = lambda : map(int, inp().split())
lient = lambda : [int(i) for i in inp().split()]
li0 = lambda x: [0 for i in range(x)]
livalor = lambda valor, x: [valor for i in range(x)]
stent = lambda : [i for i in inp()]
filldp = lambda valor, x, y: [[valor for i in range(y)] for i in range(x)]
ab = abs
t = iinp()
for _ in range(t):
	n = iinp()
	atletas = lient()
	res = 1e+60
	for i in range(n):
		for j in range(n):
			if i != j:
				tmp = ab(atletas[i] - atletas[j])
				res = tmp if tmp < res else res
			if res == 0:
				break
		if res == 0:
			break
	print(res)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	j = 0
	ans = 0
	c = []
	for i in range(len(l)):
		for j in range(len(l)):
			if i != j and l[i] >= l[j]:
				c.append(l[i] - l[j])
	c.sort()
	print(c[0])


for _ in range(int(input())):
	input()
	num = [int(i) for i in input().split()]
	num.sort()
	minDiff = 2000
	for i in range(1, len(num)):
		diff = num[i] - num[i - 1]
		if diff < minDiff:
			minDiff = diff
	print(minDiff)


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	m = 1001
	for i in range(0, n - 1):
		if lst[i + 1] - lst[i] < m:
			m = lst[i + 1] - lst[i]
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(sorted(map(int, input().split())))
	r = [s[i + 1] - s[i] for i in range(n - 1)]
	print(min(r))


import sys
from math import sqrt, floor, factorial, gcd
from collections import deque, Counter, defaultdict
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def a():
	ans = ''
	for _ in range(int(inp())):
		(a, b) = read()
		i = 1
		while i < max(max(a, b), min(a, b) * 2) or i ** 2 < a * b * 2:
			i += 1
		ans += str(i ** 2) + '\n'
	print(ans)

def b():
	ans = ''
	for _ in range(int(inp())):
		n = int(inp())
		arr = sorted(read())
		x = 10 ** 9
		for i in range(n - 1):
			x = min(x, abs(arr[i] - arr[i + 1]))
		ans += str(x) + '\n'
	print(ans)
b()


from sys import stdin, stdout
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	v = list(map(int, stdin.readline().split(' ')))
	v.sort()
	mn = int(1e+18)
	for i in range(n - 1):
		mn = min(v[i + 1] - v[i], mn)
	stdout.write(str(mn) + '\n')


test_cases = int(input())
lst1 = []
for j in range(test_cases):
	inp1 = int(input())
	st = input()
	lst = [int(x) for x in st.split()]
	lst.sort()
	lst1.append(lst)
temp = 0
a = []
b = []
for row in lst1:
	temp = 0
	temp1 = 0
	for (ind, i) in enumerate(row):
		if ind == 0:
			temp = i
			continue
		elif ind == 1 and len(row) == 2:
			print(abs(row[0] - row[1]))
			break
		elif ind == 1:
			temp1 = abs(temp - i)
			temp = i
		elif abs(temp - i) < temp1 and ind == len(row) - 1:
			temp1 = abs(temp - i)
			temp = i
			print(temp1)
		elif ind == len(row) - 1:
			print(temp1)
		elif abs(temp - i) < temp1:
			temp1 = abs(temp - i)
			temp = i
		else:
			temp = i


import math
t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	min = abs(s[0] - s[1])
	for j in range(len(s)):
		for k in range(j + 1, len(s)):
			if abs(s[j] - s[k]) < min:
				min = abs(s[j] - s[k])
	print(min)


inf = 10 ** 9

def main():
	for tc in range(int(input())):
		n = int(input())
		a = sorted(list(map(int, input().split())))
		mn = inf
		for i in range(0, len(a) - 1, 1):
			mn = min(mn, a[i + 1] - a[i])
		print(mn)
main()


from sys import stdin, stdout, maxsize
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	m = maxsize
	l = list(map(int, stdin.readline().strip().split()))
	l.sort()
	for i in range(n):
		if abs(l[i - 1] - l[i]) < m:
			m = abs(l[i - 1] - l[i])
	stdout.write(str(m) + '\n')


for j in range(int(input())):
	b = int(input())
	a = sorted(list(map(int, input().split())))
	s = 1000
	for i in range(1, len(a)):
		s = min(a[i] - a[i - 1], s)
	print(s)


from sys import stdin, stdout

def input():
	return stdin.readline()
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 0
	f = 0
	for i in range(n - 1):
		if arr[i] == arr[i + 1]:
			ans = 0
			f = 1
			break
	if f == 1:
		print(ans)
	else:
		m = 100000000
		for i in range(n - 1):
			m = min(m, arr[i + 1] - arr[i])
		print(m)


def f(l):
	a = len(l)
	m = []
	l.sort()
	for x in range(1, a):
		m.append(l[x] - l[x - 1])
	return min(m)
n = int(input())
for x in range(n):
	b = int(input())
	n = input().split()
	l = []
	for y in n:
		l.append(int(y))
	print(f(l))


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	res = [a[0]]
	ans = a[0]
	for i in range(1, len(a)):
		if ans > min(res) - a[i]:
			ans = min(res) - a[i]
			if ans == 0:
				break
		res.append(a[i])
	print(ans)
	t = t - 1


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split(' ')))
	dict = {}
	for i in arr:
		if i not in dict:
			dict[i] = 1
		else:
			dict[i] += 1
	flag = 0
	for (key, val) in dict.items():
		if val != 1:
			flag = 1
			print(0)
			break
	if flag == 0:
		arr = sorted(arr)
		res = [arr[i] - arr[i - 1] for i in range(1, len(arr))]
		print(min(res))


for i in range(int(input())):
	N = int(input())
	array = sorted([int(x) for x in input().split()])
	something = [abs(array[i] - array[i - 1]) for i in range(1, N)]
	print(min(something))


for t in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ret = 99999999999999999999999999999999999999999
	for x in range(1, n):
		dif = s[x] - s[x - 1]
		if dif == 0:
			ret = 0
			break
		elif dif < ret:
			ret = dif
	print(ret)


def input_as_list():
	return list(map(int, input().split()))
tests = int(input())
for _ in range(tests):
	[athlets] = input_as_list()
	strengths = input_as_list()
	strengths.sort()
	mimimum_gap = strengths[-1]
	for i in range(athlets - 1):
		if mimimum_gap > strengths[i + 1] - strengths[i]:
			mimimum_gap = strengths[i + 1] - strengths[i]
	print(mimimum_gap)


t = int(input())
for i in range(t):
	c = 10 ** 9 + 1
	n = int(input())
	s = [int(i) for i in input().split()]
	s.sort()
	for i in range(n - 1):
		c = min(c, s[i + 1] - s[i])
	print(c)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	arr.sort()
	ans = 1001
	for i in range(len(arr) - 1):
		ans = min(ans, arr[i + 1] - arr[i])
		if ans == 0:
			break
	stdout.write(str(ans) + '\n')


for i in range(int(input())):
	input()
	lst = sorted(list(map(int, input().split())))
	ans = [lst[i] - lst[i - 1] for i in range(1, len(lst))]
	print(min(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	m = -1
	for i in range(n - 1):
		x = abs(arr[i] - arr[i + 1])
		if x < m or m == -1:
			m = x
	print(m)


def find_min(s):
	sList = s.split()
	sList = list(map(int, sList))
	sList.sort(reverse=True)
	diff = sList[0] - sList[1]
	for i in range(1, len(sList) - 1):
		if sList[i] - sList[i + 1] < diff:
			diff = sList[i] - sList[i + 1]
		if diff == 0:
			break
	return diff
n = int(input())
tList = []
for i in range(n):
	input()
	tList.append(input())
for i in tList:
	print(find_min(i))


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mi = 10000000000000000
	for i in range(1, n):
		mi = min(mi, l[i] - l[i - 1])
	print(mi)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	m = list(map(int, input().strip().split()))
	m.sort()
	ml = None
	for i in range(n - 1):
		if ml is None or m[i + 1] - m[i] < ml:
			ml = m[i + 1] - m[i]
	print(ml)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mn = 10 ** 9
	for i in range(n - 1):
		if a[i + 1] - a[i] < mn:
			mn = a[i + 1] - a[i]
	print(mn)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = s[1] - s[0]
	if n == 2:
		print(ans)
	else:
		for i in range(1, n - 1):
			ans = min(ans, s[i + 1] - s[i])
		print(ans)


def solution(s, n):
	s.sort()
	minDiff = float('inf')
	for i in range(1, n):
		if abs(s[i] - s[i - 1]) < minDiff:
			minDiff = abs(s[i] - s[i - 1])
	return minDiff
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	print(solution(s, n))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = sorted(LI())
		r = inf
		for i in range(n - 1):
			r = min(r, a[i + 1] - a[i])
		rr.append(r)
	return JA(rr, '\n')
print(main())


for _ in [0] * int(input()):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	difference = 1000
	for i in range(n - 1):
		if difference == 0:
			break
		if a[i + 1] - a[i] < difference:
			difference = a[i + 1] - a[i]
	print(difference)


import sys

def read():
	return sys.stdin.readline().strip()

def write(a):
	sys.stdout.write(a)

def solve(n, a):
	ans = 10 ** 5
	for i in range(n - 1):
		ans = min(ans, a[i + 1] - a[i])
	return ans

def bruh():
	t = int(read())
	ans = [0] * t
	for i in range(t):
		n = int(read())
		a = [int(i) for i in read().split()]
		ans[i] = solve(n, sorted(a))
	write('\n'.join(map(str, ans)))
bruh()


t = int(input())
for i in range(t):
	n = int(input())
	s = [int(j) for j in input().split()]
	s = sorted(s)
	m = 9999999999999
	for j in range(1, n):
		if s[j] - s[j - 1] < m:
			m = s[j] - s[j - 1]
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s1 = sorted(s)
	a = s1[0]
	b = s1[1]
	c = s1[1] - s1[0]
	for j in range(len(s1) - 1):
		if s1[j + 1] - s1[j] < c:
			a = s1[j]
			b = s1[j + 1]
			c = s1[j + 1] - s1[j]
		if c == 0:
			break
	print(c)


import sys
TEST = 0
if TEST == 1:
	input_file = open('inputB.txt', 'r')
	input_from_file = input_file.readlines()

def read_int():
	if TEST:
		return int(input_from_file.pop(0))
	else:
		return int(sys.stdin.readline())

def read_ints():
	if TEST:
		return list(map(int, input_from_file.pop(0).rstrip().split()))
	else:
		return list(map(int, sys.stdin.readline().split()))

def read_str_to_list():
	if TEST:
		in1 = input_from_file.pop(0).rstrip()
	else:
		in1 = sys.stdin.readline()
	return in1
t = read_int()
for test in range(t):
	N = read_int()
	S = read_ints()
	S.sort()
	minDelta = max(S) - min(S)
	for j in range(len(S) - 1):
		delta = S[j + 1] - S[j]
		if delta < minDelta:
			minDelta = delta
	print(minDelta)


t = int(input())
i = 0
while i < t:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	d = []
	for x in range(1, n):
		a = arr[x] - arr[x - 1]
		d.append(a)
	print(min(d))
	i = i + 1


t = int(input())
arr = []
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort(reverse=True)
	for i in range(0, len(s)):
		for k in range(0, len(s)):
			if k == i:
				continue
			else:
				ele = s[i] - s[k]
				arr.append(ele)
	m = min((i for i in arr if i >= 0))
	print(m)
	arr = []


def HonestCoach(arr, n):
	arr.sort()
	ans = 1000
	for i in range(0, len(arr) - 1):
		if arr[i + 1] - arr[i] < ans:
			ans = arr[i + 1] - arr[i]
			if ans == 0:
				break
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	res = HonestCoach(arr, n)
	print(res)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	l = list(map(int, sys.stdin.readline().split()))
	l.sort()
	mini = abs(l[0] - l[1])
	for i in range(1, n):
		if abs(l[i] - l[i - 1]) < mini:
			mini = abs(l[i] - l[i - 1])
	print(mini)


n = int(input())
for i in range(n):
	a = int(input())
	b = [int(j) for j in input().split(' ')]
	b.sort()
	mini = 10 ** 9
	for j in range(a - 1):
		if b[j + 1] - b[j] < mini:
			mini = b[j + 1] - b[j]
	print(mini)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k = []
	k = list(dict.fromkeys(a))
	smallest = 1000000000
	if len(a) != len(k):
		print('0')
	else:
		a.sort()
		for i in range(0, n - 1):
			if a[i + 1] - a[i] < smallest:
				smallest = a[i + 1] - a[i]
		print(smallest)


from sys import stdin, stdout
input = stdin.readline

def print(x):
	stdout.write(str(x) + '\n')
mod = 10 ** 9 + 7

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	minn = 10 ** 9
	for i in range(n - 1):
		minn = min(l[i + 1] - l[i], minn)
	print(minn)
t = 1
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	diff = 10 ** 9
	for i in range(1, n):
		if arr[i] - arr[i - 1] < diff:
			diff = arr[i] - arr[i - 1]
	print(diff)


testcases = int(input())
for _ in range(testcases):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = pow(2, 31)
	for i in range(n - 1):
		ans = min(ans, l[i + 1] - l[i])
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	ath = list(map(int, input().split()))
	ath.sort()
	diff = ath[1] - ath[0]
	for i in range(len(ath) - 1):
		diff = min(ath[i + 1] - ath[i], diff)
	print(diff)


n = int(input())
for i in range(n):
	nn = int(input())
	arr = sorted([int(k) for k in input().split(' ')])
	print(min([t - s for (s, t) in zip(arr, arr[1:])]))


for i in range(int(input())):
	n = int(input())
	myathlet = list(map(int, input().split()))
	my = []
	sort_list = sorted(myathlet)
	for i in range(n - 1):
		my.append(sort_list[i + 1] - sort_list[i])
	print(min(my))


for _ in range(int(input())):
	a = int(input())
	s = sorted(map(int, input().split()))
	res = s[1] - s[0]
	for i in range(1, len(s)):
		if res > s[i] - s[i - 1]:
			res = s[i] - s[i - 1]
	print(res)


a = int(input())
for i in range(a):
	a = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	k = []
	for j in range(len(l) - 1):
		k.append(l[j + 1] - l[j])
	print(min(k))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = 1005
	for i in range(n):
		for j in range(i + 1, n):
			if abs(a[i] - a[j]) < m:
				m = abs(a[i] - a[j])
		if m == 0:
			break
	print(m)


t = int(input())
while t:
	n = int(input())
	ls = list(map(int, input().split()))
	res = 10 ** 5
	for i in range(n):
		for j in range(n):
			if i != j:
				res = min(res, abs(ls[i] - ls[j]))
	print(res)
	t -= 1


n_global = int(input())
A = [0] * 2
localmin = 2000000000000000000000
for i in range(n_global):
	localmin = 2000000000000000000000
	n = int(input())
	A = list(map(int, input().split()))
	for j in range(n):
		for j1 in range(n):
			if j != j1:
				localmin = min(localmin, abs(A[j] - A[j1]))
	print(localmin)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mi = abs(a[0] - a[1])
	for i in range(n):
		for j in range(i + 1, n):
			mi = min(mi, abs(a[i] - a[j]))
	print(mi)


import sys
import heapq

def main():
	t = int(input())
	for _ in range(t):
		n = int(sys.stdin.readline().strip())
		nums = list(map(int, sys.stdin.readline().split()))
		nums.sort()
		ans = nums[1] - nums[0]
		for i in range(1, n):
			ans = min(ans, nums[i] - nums[i - 1])
		print(ans)
	return
main()


for i in range(int(input())):
	n = int(input())
	s = input().split(' ')
	s = [int(i) for i in s]
	s = sorted(s)
	best = 10000
	for i in range(n - 1):
		new = abs(int(s[i]) - int(s[i + 1]))
		if new < best:
			best = new
	print(best)


no_of_test_cases = int(input())
for _ in range(no_of_test_cases):
	listt = []
	length = int(input())
	strength = input().split()
	for el in strength:
		listt.append(int(el))
	mini = abs(listt[1] - listt[0])
	for i in range(length):
		for j in range(i + 1, length):
			if abs(listt[i] - listt[j]) < mini:
				mini = abs(listt[i] - listt[j])
	print(mini)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	res = max(l)
	for i in range(len(l) - 1):
		x = abs(l[i] - l[i + 1])
		if l[i] == l[i + 1]:
			res = 0
			break
		elif res > x:
			res = x
	print(res)


N = int(input())
for i in range(N):
	n = int(input())
	L = list(map(int, input().split()))
	L.sort()
	ans = 10 ** 9
	for j in range(1, n):
		ans = min(ans, L[j] - L[j - 1])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	arr = []
	for i in range(n):
		for j in range(i + 1, n):
			arr.append(abs(l[i] - l[j]))
	print(min(arr))


def rs():
	return input().strip()

def ri():
	return int(input())

def ria():
	return list(map(int, input().split()))

def ia_to_s(a):
	return ' '.join([str(s) for s in a])

def solve(n, s):
	s = sorted(s, reverse=True)
	m = abs(s[1] - s[0])
	for i in range(1, n):
		m = min(m, abs(s[i] - s[i - 1]))
	return m

def main():
	for _ in range(ri()):
		n = ri()
		s = ria()
		print(solve(n, s))
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(s) for s in input().split()]
	a.sort()
	m = 2 ** 63
	for j in range(n - 1):
		if a[j + 1] - a[j] < m:
			m = a[j + 1] - a[j]
	print(m)


t = int(input())
for x in range(t):
	n = int(input())
	L = list(map(int, input().strip().split(' ')))
	L.sort()
	arr = []
	for i in range(1, n):
		arr.append(L[i] - L[i - 1])
	arr.sort()
	print(arr[0])


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	minn = 99999
	for i in range(n - 1):
		if abs(arr[i + 1] - arr[i]) < minn:
			minn = abs(arr[i + 1] - arr[i])
	print(minn)


def main():
	t = int(input())
	for __ in range(t):
		n = int(input())
		a = sorted(list(map(int, input().split())))
		ans = 10001
		for i in range(1, n):
			ans = min(ans, abs(a[i] - a[i - 1]))
		print(ans)
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	minimum = 100000000000000000
	for j in range(n):
		for k in range(j + 1, n):
			if abs(a[j] - a[k]) < minimum:
				minimum = abs(a[j] - a[k])
	print(minimum)


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	d = math.inf
	for i in range(1, n):
		d = min(d, abs(a[i] - a[i - 1]))
	print(d)


def one_case():
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	minx = 999999
	for i in range(len(a) - 1):
		x = a[i + 1] - a[i]
		if x < minx:
			minx = x
	print(minx)
t = int(input())
for i in range(t):
	one_case()


for _ in range(int(input())):
	n = int(input())
	strengths = list(map(int, input().split()))
	strengths.sort()
	ans = 1000
	for i in range(1, n):
		ans = min(ans, strengths[i] - strengths[i - 1])
	print(ans)


import sys
f_in = sys.stdin
f_out = sys.stdout
i = int(f_in.readline())
for _ in range(i):
	n = int(f_in.readline())
	athlete = f_in.readline().split(' ')
	athlete = [int(x) for x in athlete]
	athlete.sort()
	mininum = athlete[1] - athlete[0]
	for s in range(2, n):
		if athlete[s] - athlete[s - 1] < mininum:
			mininum = athlete[s] - athlete[s - 1]
	f_out.write(str(mininum) + '\n')


for i in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	l.sort()
	l1 = []
	for i in range(a - 1):
		x = l[i + 1] - l[i]
		l1.append(x)
	print(min(l1))


t = int(input())
for i in range(t):
	n = int(input())
	arr1 = input().split(' ')
	arr = []
	m = 10000
	for i in range(n):
		arr = arr + [int(arr1[i])]
	arr.sort()
	for i in range(1, n):
		m = min(m, arr[i] - arr[i - 1])
	print(m)


from sys import stdin
for i in range(int(input())):
	t = int(input())
	a = [int(x) for x in stdin.readline().split()]
	d = abs(a[0] - a[1])
	for j in range(t - 1):
		for j1 in range(j + 1, t):
			d = min(abs(a[j] - a[j1]), d)
	print(d)


def get_min_gap(power, n):
	power.sort()
	mini = 100000
	for i in range(1, n):
		gap = power[i] - power[i - 1]
		mini = min(mini, gap)
	return mini
T = int(input())
for t in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	print(get_min_gap(arr, n))


import math
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mini = math.inf
	for i in range(1, len(arr)):
		if arr[i] - arr[i - 1] < mini:
			mini = arr[i] - arr[i - 1]
	print(mini)


for ii in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	ans = 10 ** 7
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


for ib in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mi = max(a) - min(a)
	mu = 0
	for i in range(1, n):
		if a[i] - a[i - 1] < mi:
			mi = a[i] - a[i - 1]
	print(mi)


test = int(input())
while test != 0:
	n = int(input())
	a = input()
	a = a.split()
	ans = 1000000000000000000
	a = [int(i) for i in a]
	a.sort()
	for i in range(len(a) - 1):
		ans = min(ans, abs(a[i + 1] - a[i]))
	print(ans)
	test -= 1


t = int(input())
for i in range(t):
	n = int(input())
	l = input().split()
	l1 = [int(x) for x in l]
	l = len(l1)
	a = []
	b = []
	l1.sort()
	mindif = []
	if len(l1) != 2:
		for i in range(0, len(l1) - 1):
			mindif.append(abs(l1[i] - l1[i + 1]))
		print(min(mindif))
	else:
		mindif = abs(l1[0] - l1[1])
		print(mindif)


def f(L, n):
	L.sort()
	C = []
	C.append(abs(L[1] - L[0]))
	for i in range(n):
		C.append(abs(L[i] - L[i - 1]))
	return min(C)
t = int(input())
while t > 0:
	n = int(input())
	C = list(map(int, input().split()))
	print(f(C, n))
	t -= 1


import sys
import math
from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	i = n - 1
	a.sort()
	ans = math.inf
	while i >= 1:
		if a[i] - a[i - 1] <= ans:
			ans = a[i] - a[i - 1]
		i -= 1
	print(ans)


t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().rstrip().split(' ')))
	l.sort()
	m = 99999999
	for i in range(n - 1):
		mi = l[i + 1] - l[i]
		if mi < m:
			m = mi
	print(m)
	t -= 1


import sys

def process():
	_ = sys.stdin.readline()
	a = [int(s) for s in sys.stdin.readline().split()]
	a.sort()
	mn = a[-1]
	for i in range(len(a) - 1):
		m = a[i + 1] - a[i]
		mn = min(mn, m)
	print(mn)
T = int(sys.stdin.readline())
for x in range(T):
	process()


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
sys.setrecursionlimit(10 ** 5)

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def solve():
	n = II()
	l = sorted(LI())
	count = 10 ** 10
	for i in range(n - 1):
		flag = l[i + 1] - l[i]
		if flag <= count:
			count = flag
	print(count)
for _ in range(II()):
	solve()


t = int(input())
while t != 0:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 999999
	for i in range(n - 1):
		diff = arr[i + 1] - arr[i]
		ans = min(ans, diff)
	print(ans)
	t -= 1


r = int(input())
m = 999999
for t in range(0, r):
	n = int(input())
	a = []
	a = list(map(int, input().strip().split()))[:n]
	a = sorted(a)
	m = a[1] - a[0]
	for i in range(2, n):
		x = a[i] - a[i - 1]
		if x < m:
			m = x
	print(m)


def solve(n, arr):
	arr.sort()
	diff = arr[1] - arr[0]
	for i in range(2, n):
		if arr[i] - arr[i - 1] < diff:
			diff = arr[i] - arr[i - 1]
	return diff
t = int(input())
for _ in range(t):
	inp = input().split()
	n = int(inp[0])
	arr = [int(x) for x in input().split()]
	print(solve(n, arr))


t = int(input())

def fun(l, n):
	l.sort()
	u = []
	for _ in range(n - 1):
		u.append(l[_ + 1] - l[_])
	return min(u)
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(fun(a, n))


for i in range(int(input())):
	n = int(input())
	a = [int(j) for j in input().split()]
	a = sorted(a)
	ans = 1000000007
	for j in range(1, n):
		ans = min(ans, a[j] - a[j - 1])
	print(ans)


import sys
t = int(sys.stdin.readline())
ans_arr = []
for i in range(t):
	n = int(sys.stdin.readline())
	s = [int(j) for j in sys.stdin.readline().split()]
	s.sort()
	ans = s[1] - s[0]
	for g in range(n - 1):
		ans = min(ans, s[g + 1] - s[g])
	ans_arr.append(str(ans))
print('\n'.join(ans_arr))


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	d = []
	s.sort()
	for x in range(n - 1):
		d.append(s[x + 1] - s[x])
	print(min(d))


n = int(input())
for i in range(n):
	e = 100000
	b = int(input())
	l = []
	l = [int(c) for c in input().strip().split()]
	l.sort()
	for k in range(b - 1):
		if l[k + 1] - l[k] < e:
			e = l[k + 1] - l[k]
	print(e)


def find(s, n):
	s.sort()
	best = s[1] - s[0]
	i = 0
	while i < n - 1:
		best = min(best, s[i + 1] - s[i])
		i += 1
	return best
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	print(find(s, n))


numb = int(input())
for n in range(numb):
	ath = int(input())
	skills = str(input()).split(' ')
	n = 0
	while n < ath - 1:
		if int(skills[n]) > int(skills[n + 1]):
			(skills[n], skills[n + 1]) = (skills[n + 1], skills[n])
			n = 0
		else:
			n += 1
	x = int(skills[1]) - int(skills[0])
	for m in range(ath - 1):
		if int(skills[m + 1]) - int(skills[m]) < x:
			x = int(skills[m + 1]) - int(skills[m])
	print(x)


for i1 in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	min = 10000
	for i in range(n - 1):
		temp = l[i + 1] - l[i]
		if temp < min:
			min = temp
	print(min)


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	z = []
	for i in range(0, len(a) - 1):
		z.append(abs(a[i] - a[i + 1]))
	print(min(z))


import sys
t = int(input())
for i in range(t):
	n = int(input())
	arg = input().split(' ')
	a = []
	a.append(int(arg[0]))
	ans = abs(int(arg[0]) - int(arg[1]))
	for j in range(1, n):
		a.append(int(arg[j]))
	a.sort()
	for j in range(1, n):
		ans = min(a[j] - a[j - 1], ans)
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().strip(' ').split()))
	l.sort()
	mi = 99999
	for i in range(0, n - 1):
		if l[i + 1] - l[i] <= mi:
			mi = l[i + 1] - l[i]
	print(mi)
	t = t - 1


testy = int(input())
results = []
for i in range(testy):
	trash = input()
	wejscie = list(map(int, input().split()))
	mingap = 1000
	wejscie.sort()
	for i in range(0, len(wejscie) - 1):
		if wejscie[i + 1] - wejscie[i] < mingap:
			mingap = wejscie[i + 1] - wejscie[i]
	results.append(mingap)
for result in results:
	print(result)


t = int(input())
while t:
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	p = []
	for i in range(0, len(l) - 1):
		p.append(l[i + 1] - l[i])
	print(min(p))
	t = t - 1


cases = int(input())
for case in range(cases):
	n = int(input())
	s = list(map(int, input().rstrip().split()))
	s.sort()
	minDiff = abs(s[1] - s[0])
	for i in range(n - 1):
		if abs(s[i + 1] - s[i]) < minDiff:
			minDiff = abs(s[i + 1] - s[i])
	print(minDiff)


T = int(input())
for t in range(T):
	n = int(input())
	l = sorted(list(map(int, input().rstrip().split())))
	minimo = l[n - 1] - l[0]
	for i in range(n - 1):
		minimo = min(minimo, l[i + 1] - l[i])
	print(minimo)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	s = list(map(int, input().split()))
	d = sorted(s)
	min1 = float('inf')
	for i in range(len(d) - 1):
		z = d[i + 1] - d[i]
		min1 = min(min1, z)
	print(min1)


test = int(input())
for t in range(test):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	mini = 100000
	for i in range(1, n):
		if lst[i] - lst[i - 1] < mini:
			mini = lst[i] - lst[i - 1]
	print(mini)


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr = sorted(arr)
	mini = 1001
	i = n - 1
	while i > 0:
		if arr[i] - arr[i - 1] <= mini:
			mini = arr[i] - arr[i - 1]
		i -= 1
	print(mini)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	m = 10000
	for p in range(n - 1):
		m = min(m, a[p + 1] - a[p])
	print(m)


t = int(input())
while t > 0:
	n = int(input())
	lst = list(map(int, input().split()))
	s_lst = sorted(lst)
	ans = s_lst[1] - s_lst[0]
	for i in range(2, n):
		ans = min(ans, s_lst[i] - s_lst[i - 1])
	print(ans)
	t -= 1


cases = int(input())
for x in range(0, cases):
	lenght = int(input())
	sequence = [int(x) for x in input().split()]
	min_val = 10001
	sequence = sorted(sequence)
	for x in range(0, lenght - 1):
		min_val = min(min_val, sequence[x + 1] - sequence[x])
	print(min_val)


test_cases = int(input())
for _ in range(test_cases):
	n = int(input())
	array = sorted([int(i) for i in input().split(' ')])
	diff = abs(array[0] - array[1])
	for i in range(1, n - 1):
		diff = min(diff, abs(array[i] - array[i + 1]))
	print(diff)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	ans = 10 ** 18
	for i in range(n - 1):
		ans = min(ans, abs(A[i] - A[i + 1]))
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	x = set(a)
	if n == 1:
		print(a[0])
	elif n == 2:
		print(abs(a[1] - a[0]))
	elif len(x) != n:
		print(0)
	else:
		a.sort()
		m = 9999999999999999999
		for i in range(n - 1):
			if a[i + 1] - a[i] < m:
				m = a[i + 1] - a[i]
		print(m)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = []
	l.sort()
	for i in range(len(l) - 1):
		x.append(l[i + 1] - l[i])
	print(min(x))


t = int(input(''))
for i in range(0, t):
	n = int(input(''))
	s = input('').split()
	s = [int(q) for q in s]
	s.sort()
	S = len(s)
	foo = []
	x = True
	for j in range(0, 1000):
		if x == False:
			break
		else:
			for k in range(0, S - 1):
				if s[k] == s[k + 1] - j:
					print(j)
					x = False
					break


from sys import stdin as lector
input = lector.readlines()
n = int(input[0])
for i in range(2, 2 * n + 1, 2):
	lista = input[i].split(' ')
	numeros = list(map(lambda x: int(x), lista))
	orden = sorted(numeros)
	min = abs(orden[1] - orden[0])
	for j in range(len(orden) - 1, 0, -1):
		if orden[j] - orden[j - 1] < min:
			min = orden[j] - orden[j - 1]
	print(min)


num = int(input(''))
i = 0
while i < num:
	num2 = int(input(''))
	arr_ = input('').split()
	arr = []
	for k in arr_:
		arr.append(int(k))
	arr.sort()
	min = abs(int(arr[1]) - int(arr[0]))
	for j in range(num2 - 1):
		diff = abs(int(arr[j]) - int(arr[j + 1]))
		if diff < min:
			min = diff
	print(min)
	i += 1


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	a = [int(x) for x in inp().split()]
	a.sort()
	minDiff = 1001
	for i in range(1, n):
		minDiff = min(minDiff, a[i] - a[i - 1])
	print(minDiff)


for zx in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	e = []
	for i in range(n - 1):
		r = a[i + 1] - a[i]
		e.append(r)
	print(min(e))


t = int(input())
for _ in range(t):
	l1 = int(input())
	l2 = list(map(int, input().split()))
	A = sorted(l2)
	min_diff = 1001
	for i in range(l1 - 1):
		min_diff = min(min_diff, A[i + 1] - A[i])
	print(min_diff)


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort()
	c = []
	for i in range(1, n):
		c.append(arr[i] - arr[i - 1])
	print(min(c))


def count():
	(n, s) = (int(input()), sorted(list(map(int, input().split()))))
	ans = []
	for i in range(n - 1):
		ans.append(s[i + 1] - s[i])
	return min(ans)
for i in range(int(input())):
	print(count())


TEST = int(input())
for i in range(TEST):
	n = int(input())
	weights = [int(i) for i in input().split()]
	weights = sorted(weights)
	W = weights[1] - weights[0]
	for i in range(n - 1):
		W = min(W, weights[i + 1] - weights[i])
	print(W)


import heapq as hp
import collections

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int):
	return sorted(map(func, input().split()))

def range_n():
	return range(int(input()))

def main():
	for _ in range_n():
		n = int(input())
		a = s_unpack()
		ans = a[-1] - a[0]
		for i in range(n - 1):
			ans = min(ans, a[i + 1] - a[i])
		print(ans)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = sorted(map(int, input().split()))
	ans = float('inf')
	for i in range(len(arr) - 1):
		ans = min(ans, arr[i + 1] - arr[i])
	print(ans)


import math
for w in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	dif = abs(a[0] - a[1])
	for i in range(1, n - 1):
		if abs(a[i] - a[i + 1]) < dif:
			dif = abs(a[i] - a[i + 1])
		if dif == 0:
			break
	print(dif)


import sys
input = sys.stdin.readline
t = int(input())
for t1 in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	l.sort()
	diff = 100000000
	for i in range(1, n):
		diff = min(l[i] - l[i - 1], diff)
	print(diff)


t = int(input())
for i in range(t):
	n = int(input())
	b = []
	a = list(map(int, input().split()))
	a.sort()
	k = 10001
	for i in range(n - 1):
		k = a[i + 1] - a[i]
		b.append(k)
	b.sort()
	print(b[0], '\n')


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	l1 = list(map(int, input().split()))
	min1 = pow(10, 10)
	l1.sort()
	for i in range(n - 1):
		v = l1[i + 1] - l1[i]
		min1 = min(min1, v)
		if min1 == 0:
			print(0)
			return
	print(min1)
for _ in range(int(input())):
	solve()


import os
import sys
from io import BytesIO, IOBase

def readvars():
	k = map(int, input().split())
	return k

def readlist():
	li = list(map(int, input().split()))
	return li

def anslist(li):
	ans = ' '.join([str(v) for v in li])
	return ans

def main():
	t = 1
	t = int(input())
	for xx in range(t):
		n = int(input())
		s = readlist()
		s.sort()
		mind = s[-1] - s[0]
		for i in range(1, n):
			mind = min(mind, s[i] - s[i - 1])
		print(mind)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
for z in range(int(input())):
	n = int(input())
	s = []
	inp = input().split()
	for i in range(n):
		s.append(int(inp[i]))
	s = sorted(s)
	mini = 1000000000
	for i in range(1, n):
		diff = s[i] - s[i - 1]
		if diff < mini:
			mini = diff
	print(mini)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	minDiff = float('inf')
	for i in range(1, n):
		d = arr[i] - arr[i - 1]
		if d < minDiff:
			minDiff = d
	print(minDiff)


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	result = 1 << 31
	for i in range(1, len(arr)):
		if arr[i] - arr[i - 1] < result:
			result = arr[i] - arr[i - 1]
	print(result)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort()
	m = 10000000
	for i in range(n - 1):
		m = min(arr[i + 1] - arr[i], m)
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	lst = []
	l.sort()
	for i in range(n - 1):
		res = abs(l[i] - l[i + 1])
		lst.append(res)
	print(min(lst))


t = int(input())
while t != 0:
	n = int(input())
	arr = list(map(int, input().split()))[:n]
	arr.sort()
	minD = float('inf')
	for i in range(n - 1):
		minD = min(abs(arr[i] - arr[i + 1]), minD)
	print(minD)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split(' ')))
	ar.sort()
	diff = ar[1] - ar[0]
	for j in range(2, n):
		if abs(ar[j] - ar[j - 1]) < diff:
			diff = abs(ar[j] - ar[j - 1])
	print(diff)


num_cases = int(input())
for _ in range(num_cases):
	num_ath = int(input())
	x = input().strip().split()
	x = [int(a) for a in x]
	x.sort()
	mini = 2000
	for i in range(len(x) - 1):
		mini = min(mini, x[i + 1] - x[i])
	print(mini)


t = int(input())
l = []
for i in range(0, t):
	n = int(input())
	m = [int(x) for x in input().split()]
	l.append(m)
for j in range(0, t):
	k = l[j]
	k.sort()
	ll = []
	for p in range(0, len(k) - 1):
		d = abs(k[p + 1] - k[p])
		ll.append(d)
	print(min(ll))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	m = 100000
	for i in range(len(l) - 1):
		m = min(m, abs(l[i] - l[i + 1]))
	print(m)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	p = float('inf')
	for i in range(1, n):
		q = a[i] - a[i - 1]
		if q < p:
			p = q
	print(p)


n = int(input())
for i in range(n):
	n1 = int(input())
	x = sorted(list(map(int, input().split())))
	y = list(map(lambda x, y: y - x, x[0:n1 - 1], x[1:n1]))
	print(min(y))


x = int(input())
for i in range(x):
	y = int(input())
	l = list(map(int, input().split()))
	m = 100000000000000000000000000000000000000000
	l.sort()
	for i in range(len(l) - 1):
		if m > l[i + 1] - l[i]:
			m = l[i + 1] - l[i]
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	line = input()
	po = line.split()
	lis = list()
	for j in po:
		lis.append(int(j))
	lis.sort(reverse=True)
	mi = None
	for j in range(n - 1):
		temp = lis[j] - lis[j + 1]
		if mi is None:
			mi = temp
		elif mi > temp:
			mi = temp
	print(mi)


import math
t = int(input())
for t in range(0, t):
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	min_d = math.inf
	for i in range(0, n - 1):
		d = s[i + 1] - s[i]
		min_d = min(d, min_d)
	print(min_d)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().strip().split()))
	s = [0 for j in range(n - 1)]
	l.sort()
	for j in range(n - 1):
		s[j] = l[j + 1] - l[j]
	print(min(s))


t = int(input())
while t > 0:
	n = int(input())
	l = input().split()
	s = [int(i) for i in l]
	s.sort()
	M = 1000000
	i = n - 1
	while i >= 1:
		if s[i] - s[i - 1] < M:
			M = s[i] - s[i - 1]
		i -= 1
	print(M)
	t -= 1


for _ in range(int(input())):
	a = int(input())
	l = map(int, input().split())
	l = list(l)
	l.sort()
	mn = sum(l)
	for i in range(1, a):
		ans = l[i] - l[i - 1]
		if ans < mn:
			mn = ans
	print(mn)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	m = 2000
	for i in range(n - 1):
		if abs(l[i] - l[i + 1]) < m:
			m = abs(l[i] - l[i + 1])
	print(m)


def findMinDiff(arr, n):
	diff = 10 ** 20
	for i in range(n - 1):
		for j in range(i + 1, n):
			if abs(arr[i] - arr[j]) < diff:
				diff = abs(arr[i] - arr[j])
	return diff
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(findMinDiff(arr, n))


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	minn = 10000
	for i in range(n):
		for j in range(n):
			if i != j:
				if abs(s[i] - s[j]) < minn:
					minn = abs(s[i] - s[j])
	print(minn)


import collections
from functools import lru_cache

def solve(n, arr):
	INF = float('inf')
	NEG_INF = float('-inf')
	arr.sort()

	@lru_cache(None)
	def go(i, maxIndexInA):
		if i == n:
			if 0 <= maxIndexInA < n:
				minIndexInB = 1 if maxIndexInA == 0 else maxIndexInA - 1
				return abs(arr[maxIndexInA] - arr[minIndexInB])
			return INF
		return min(go(i + 1, i), go(i + 1, maxIndexInA))
	return go(0, -1)
t = int(input().strip())
for i in range(t):
	n = int(input().strip())
	arr = list(map(int, input().strip().split()))
	print(solve(n, arr))


from sys import stdin
t = int(stdin.readline())
while t > 0:
	n = int(stdin.readline())
	a = [int(x) for x in stdin.readline().split()]
	a.sort()
	minimum = a[1] - a[0]
	for i in range(2, n):
		if a[i] - a[i - 1] <= minimum:
			minimum = a[i] - a[i - 1]
	print(minimum)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 2:
		print(abs(l[0] - l[1]))
	else:
		l.sort()
		c = 0
		dif = []
		while c < len(l) - 1:
			dif.append(abs(l[c] - l[c + 1]))
			c += 1
		print(min(dif))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	m = 100000.0
	for i in range(n - 1):
		if abs(l[i + 1] - l[i]) < m:
			m = abs(l[i + 1] - l[i])
	print(m)


T = int(input())
for test in range(T):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 10 ** 9
	for i in range(1, n):
		if l[i] - l[i - 1] < ans:
			ans = l[i] - l[i - 1]
	print(ans)


for _ in range(0, int(input())):
	nem = int(input())
	aer = list(map(int, input().split()))
	aer.sort()
	print(min((abs(aer[i] - aer[i + 1]) for i in range(0, nem - 1))))


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	n = get_int()
	ls = get_list()
	ls.sort()
	mini = float('inf')
	for i in range(1, n):
		mini = min(mini, ls[i] - ls[i - 1])
	print(mini)

def main():
	solve()
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


t = int(input())
for i in range(t):
	m = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mx = l[-1]
	for i in range(m - 1):
		if mx > l[i + 1] - l[i]:
			mx = l[i + 1] - l[i]
	print(mx)


rw = int(input())
for ewqr in range(rw):
	n = int(input())
	s = list(map(int, input().split()))
	m = 10000000000
	s.sort()
	for i in range(1, n):
		m = min(m, abs(s[i] - s[i - 1]))
	print(m)


t = int(input())
res = []
for i in range(t):
	n = int(input())
	weights = sorted([int(w) for w in input().split()])
	minDelta = abs(weights[1] - weights[0])
	for i in range(1, len(weights) - 1):
		minDelta = min(minDelta, abs(weights[i + 1] - weights[i]))
	res.append(minDelta)
for r in res:
	print(r)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	s = input().split()
	for i in range(n):
		s[i] = int(s[i])
	s.sort()
	ans = 10000000
	for i in range(1, n):
		ans = min(ans, s[i] - s[i - 1])
	print(ans)


for _t in range(0, int(input())):
	n = int(input())
	t = list(map(int, input().split()))
	t.sort()
	dif = abs(t[1] - t[0])
	for p in range(1, n):
		if abs(t[p] - t[p - 1]) < dif:
			dif = abs(t[p] - t[p - 1])
	print(dif)


n = int(input())
for _ in range(n):
	l = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	m = abs(a[0] - a[1])
	for i in range(len(a) - 1):
		mi = abs(a[i] - a[i + 1])
		if mi <= m:
			m = mi
	print(m)


for i in range(int(input())):
	out = 1000000000
	n = int(input())
	x = [int(p) for p in input().split()]
	x.sort()
	for item in range(1, n):
		out = min(out, abs(x[item] - x[item - 1]))
	print(out)


import sys
from collections import defaultdict as dd
import heapq
import math
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for i in range(int(input())):
	q = int(input())
	w = sorted(list(map(int, input().split())))
	d = w[-1]
	for i in range(q - 1):
		d = min(d, w[i + 1] - w[i])
	print(d)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	trash = input()
	list_ = inlt()
	list_ = sorted(list_)
	diff = 10 ** 20
	for i in range(len(list_) - 1):
		if list_[i + 1] - list_[i] < diff:
			diff = list_[i + 1] - list_[i]
	print(diff)


n = int(input())
from math import *
for _ in range(n):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	diff = [abs(l[i + 1]) - l[i] for i in range(n - 1)]
	print(min(diff))


for _ in range(0, int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	sarr = arr
	dic = {}
	split = -1
	for i in sarr:
		if i in dic:
			dic[i] += 1
			split = i
			break
		else:
			dic[i] = 1
	if split > 0:
		print(0)
	elif len(sarr) % 2 == 0:
		difarr = []
		for i in range(0, len(sarr) - 1):
			difarr.append(abs(sarr[i] - sarr[i + 1]))
		print(min(difarr))
	else:
		difarr = []
		for i in range(0, len(sarr) - 1):
			difarr.append(abs(sarr[i] - sarr[i + 1]))
		print(min(difarr))


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	for _ in range(II()):
		n = II()
		aa = LI()
		aa.sort()
		mn = 10 ** 9
		for i in range(n - 1):
			mn = min(mn, aa[i + 1] - aa[i])
		print(mn)
main()


ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda : int(input())
ip = lambda : [int(w) for w in input().split()]
for _ in range(inp()):
	n = inp()
	x = ip()
	x.sort()
	mn = float('inf')
	for i in range(n - 1):
		mn = min(mn, x[i + 1] - x[i])
	print(mn)


t = int(input())
for i in range(t):
	n = int(input())
	k = list(map(int, input().split()))
	k = sorted(k)
	ans = 10000000
	for i in range(n - 1):
		if k[i] > k[i + 1]:
			if k[i] - k[i + 1] < ans:
				ans = k[i] - k[i + 1]
		elif k[i + 1] - k[i] < ans:
			ans = k[i + 1] - k[i]
	print(ans)


test = int(input())
INF = 1000000000000.0
respostas = []
for x in range(test):
	n = int(input())
	forca = list(map(int, input().split()))
	forca.sort()
	menor = INF
	i = 0
	j = 1
	while j != n:
		subtracao = abs(forca[i] - forca[j])
		if subtracao <= menor:
			menor = subtracao
		i += 1
		j += 1
	respostas.append(menor)
for x in respostas:
	print(x)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	dif = list((a[i] - a[i - 1] for i in range(1, n)))
	print(min(dif))


num_tests = int(input())
for _ in range(num_tests):
	_num_athletes = int(input())
	strengths = [int(x) for x in input().split()]
	strengths.sort()
	min_diff = strengths[-1] - strengths[0]
	for (a, b) in zip(strengths, strengths[1:]):
		min_diff = min(min_diff, b - a)
	print(min_diff)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ', n - 1)))
	a.sort()
	res = [0] * (n - 1)
	res[0] = a[0]
	for j in range(1, n):
		res[j - 1] = a[j] - a[j - 1]
	print(min(res))


inpt = int(input())
for i in range(inpt):
	test = int(input())
	lst = [int(s) for s in list(input().split())]
	lst.sort()
	result = lst[test - 1] - lst[test - 2]
	for i in range(test - 1, 0, -1):
		for j in range(i - 1, -1, -1):
			result = min(result, lst[i] - lst[j])
	print(result)


num_case = int(input())
cases = []
for k in range(num_case):
	num = input()
	case = input().split()
	case = [int(i) for i in case]
	case.sort()
	cases.append(case)
for k in range(num_case):
	case = cases[k]
	(pick1, pick2) = (case[0], case[1])
	(team1, team2) = ([], [])
	n = 0
	diff = pick2 - pick1
	for i in range(1, len(case) - 1):
		if case[i + 1] - case[i] < diff:
			pick2 = case[i + 1]
			pick1 = case[i]
			diff = pick2 - pick1
			n = i
	team1.append(pick1)
	for i in case[n + 2:len(case)]:
		team1.append(i)
	team2.append(pick2)
	for i in case[0:n]:
		team2.append(i)
	print(diff)


t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	mini = abs(A[1] - A[0])
	for j in range(2, n, 1):
		mini = min(abs(A[j] - A[j - 1]), mini)
	print(mini)


for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort()
	mino = arr[1] - arr[0]
	for i in range(2, n):
		mino = min(mino, arr[i] - arr[i - 1])
	print(mino)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	ans = float('inf')
	for i in range(1, n):
		for j in range(0, i):
			ans = min(ans, abs(s[i] - s[j]))
	print(ans)


def inp_n():
	return int(input())

def inp_list():
	return list(map(int, input().split()))

def inp_mul_num():
	return map(int, input().split())

def is_odd(n):
	if n & 1:
		return True
	return False
from collections import defaultdict
import math
for _ in range(inp_n()):
	n = inp_n()
	l = inp_list()
	l.sort()
	m = 9999
	for i in range(1, n):
		m = min(m, l[i] - l[i - 1])
	print(m)


t = int(input())
for z in range(t):
	n = int(input())
	in1 = [int(y) for y in input().split(' ')]
	in1.sort()
	ans1 = 1000000000.0
	for i in range(n):
		ans1 = min(ans1, abs(in1[i] - in1[i - 1]))
	print(ans1)


t = int(input())
for x in range(t):
	n = int(input())
	s = [int(i) for i in input().split()]
	s = sorted(s, reverse=True)
	m = s[0]
	for i in range(1, len(s)):
		m = min(m, int(s[:i][-1]) - int(s[i:][0]))
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().strip().split()))[:n]
	s.sort()
	mn_diff = s[1] - s[0]
	for j in range(n - 1):
		diff = s[j + 1] - s[j]
		if diff <= mn_diff:
			mn_diff = diff
	print(mn_diff)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	m = 10 ** 5
	for i in range(0, len(a) - 1):
		if abs(a[i] - a[i + 1]) < m:
			m = abs(a[i] - a[i + 1])
	print(m)


for case in range(int(input())):
	n = int(input())
	series = [int(x) for x in input().split()]
	series.sort()
	min_i = -1
	min_d = 99999999
	for i in range(1, n):
		if abs(series[i] - series[i - 1]) < min_d:
			min_d = abs(series[i] - series[i - 1])
			min_i = i
	print(abs(series[min_i] - series[min_i - 1]))


t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	ans = 10 ** 5
	for j in range(n - 1):
		ans = min(ans, A[j + 1] - A[j])
	print(ans)


n = int(input())
for i in range(n):
	leng = int(input())
	ar = input().split(' ')
	ar = sorted([int(i) for i in ar])
	mini = 100000
	for i in range(0, leng - 1):
		if ar[i + 1] - ar[i] < mini:
			mini = ar[i + 1] - ar[i]
	print(mini)


for _ in range(int(input())):
	a = int(input())
	l = sorted(list(map(int, input().split())))
	d = []
	[d.append(l[i] - l[i - 1]) for i in range(1, a)]
	print(min(d))


def Honest_coach(a, l):
	sortx = sorted(a)
	c = []
	for i in range(l):
		try:
			b = sortx[i + 1] - sortx[i]
			c.append(b)
		except IndexError:
			pass
	return min(c)
n = int(input())
for i in range(n):
	leng = int(input())
	arr = list(map(int, input().rstrip().split()))
	print(Honest_coach(arr, leng))


inp = int(input())
for x in range(0, inp):
	inp1 = input()
	inp2 = sorted(list(map(int, input().split())))
	smallest = 1000
	for num in range(0, len(inp2)):
		if num + 1 < len(inp2):
			if abs(inp2[num] - inp2[num + 1]) < smallest:
				smallest = abs(inp2[num] - inp2[num + 1])
	print(smallest)


import sys
t = int(input())
while t != 0:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	min1 = sys.maxsize
	for i in range(1, n):
		if min1 > a[i] - a[i - 1]:
			min1 = a[i] - a[i - 1]
	print(min1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	minSum = 10000000
	for i in range(0, n - 1):
		minSum = min(minSum, abs(s[i] - s[i + 1]))
	print(minSum)


for i in range(int(input())):
	minDiff = 10000
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	for i in range(1, n):
		minDiff = min(minDiff, a[i] - a[i - 1])
	print(minDiff)


t = int(input())
for _ in range(t):
	n = int(input())
	L = list(map(int, input().split()))
	c = 0
	m = 1001
	L = sorted(L)
	for i in range(len(L) - 1):
		c = L[i + 1] - L[i]
		if c < m:
			m = c
	print(m)


CaseNo = int(input())
for x in range(CaseNo):
	AthNo = int(input())
	Athlst = sorted([int(y) for y in input().split()])
	if AthNo == 1:
		print(0)
	else:
		Min = Athlst[AthNo - 1] - Athlst[0]
		for z in range(AthNo - 1):
			if Athlst[z + 1] - Athlst[z] < Min:
				Min = Athlst[z + 1] - Athlst[z]
		print(Min)


t = int(input())
for tt in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mini = 10 ** 10
	for i in range(0, n - 1):
		if l[i + 1] - l[i] < mini:
			mini = l[i + 1] - l[i]
	print(mini)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	d = float('inf')
	for i in range(len(a)):
		for j in range(len(a)):
			if i == j:
				continue
			if d > abs(a[i] - a[j]):
				d = abs(a[i] - a[j])
	print(d)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 9999
	for j in range(n - 1):
		ans = min(ans, abs(a[j] - a[j + 1]))
	print(ans)


test_cases = int(input())
for test_case in range(test_cases):
	nr_athletes = int(input())
	strength_athletes = [int(i) for i in input().split()]
	strength_athletes.sort()
	differences = [k - j for (k, j) in zip(strength_athletes[1:], strength_athletes[:-1])]
	print(min(differences))


for _ in range(int(input())):
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort(reverse=True)
	min = 100000000000000000
	for i in range(n - 1):
		if abs(ls[i] - ls[i + 1]) < min:
			min = abs(ls[i] - ls[i + 1])
	print(min)


t = int(input())
for _ in range(t):
	n = int(input())
	w = [int(i) for i in list(input().split())]
	w.sort()
	min = 1000
	for i in range(1, n):
		if min > w[i] - w[i - 1]:
			min = w[i] - w[i - 1]
	print(min)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	imin = 10001
	for k in range(n):
		for c in range(n):
			if abs(a[k] - a[c]) < imin and k != c:
				imin = abs(a[k] - a[c])
	print(imin)


for i in range(int(input())):
	num = int(input())
	total = input().split()
	temp = []
	for i in total:
		temp.append(int(i))
	total = temp
	del temp
	total = sorted(total)
	min1 = float('inf')
	for i in range(1, num):
		if min1 == 0:
			break
		val = abs(int(total[i]) - int(total[i - 1]))
		if val < min1:
			min1 = val
	print(min1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	if len(s) > 2:
		s.sort()
		maior = max(s)
		for i in range(len(s) - 1):
			if abs(s[i] - s[i + 1]) < maior:
				maior = abs(s[i] - s[i + 1])
		print(maior)
	else:
		print(max(s) - min(s))


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	x = s[1] - s[0]
	j = 1
	while j < n - 1:
		if s[j + 1] - s[j] < x:
			x = s[j + 1] - s[j]
		j = j + 1
	print(x)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	l = []
	for j in range(len(s) - 1):
		a = s[j]
		for k in range(j + 1, len(s)):
			d = abs(s[k] - a)
			l.append(d)
	print(min(l))


for _ in range(int(input())):
	n = int(input())
	athletes = list(map(int, input().split()))
	athletes.sort()
	diff = float('inf')
	for i in range(1, n):
		diff = min(diff, athletes[i] - athletes[i - 1])
	print(diff)


def solve():
	n = int(input())
	li = [int(x) for x in input().split()]
	li.sort()
	diff = 99999999999
	for i in range(n - 1):
		diff = min(diff, li[i + 1] - li[i])
	print(diff)
t = int(input())
for i in range(t):
	solve()


n = int(input())
for i in range(n):
	k = []
	m = int(input())
	s = [int(i) for i in input().split()]
	s1 = sorted(s)
	for i in range(m - 1):
		k.append(abs(s1[i] - s1[i + 1]))
	print(min(k))


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	mn = 100000
	for i in range(n - 1):
		res = a[i + 1] - a[i]
		if res < mn:
			mn = res
	print(mn)


t = int(input())
for k in range(t):
	n = int(input())
	s = list(map(int, input().split(' ')))
	s.sort(reverse=True)
	mi = 10000
	for i in range(0, n, 1):
		for j in range(i + 1, n, 1):
			x = s[i] - s[j]
			if x < mi:
				mi = x
	print(mi)


import sys
input = lambda : sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline

def I():
	return list(map(int, inp().split()))
from math import inf
for _ in range(I()[0]):
	(n,) = I()
	a = I()
	a.sort()
	minn = inf
	for i in range(len(a) - 1):
		minn = min(minn, a[i + 1] - a[i])
	print(minn)


import sys
input = lambda : sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	a = sorted([int(x) for x in input().split()])
	print(min((a[i] - a[i - 1] for i in range(1, n))))


t = int(input())
for i in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	c = []
	for j in range(len(a) - 1):
		d = a[j + 1] - a[j]
		c.append(d)
	print(min(c))


for _ in range(int(input())):
	n = int(input())
	(*x,) = map(int, input().split())
	y = sorted(x)
	k = []
	for i in range(1, n):
		k.append(y[i] - y[i - 1])
	print(min(k))


import math
for case in range(int(input())):
	n = int(input())
	a = input().split(' ')
	for i in range(n):
		a[i] = int(a[i])
	a.sort()
	minval = math.inf
	for i in range(n - 1):
		val = abs(a[i] - a[i + 1])
		if val < minval:
			minval = val
	print(minval)


def solve():
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	min_val = 1000
	for i in range(n - 1):
		diff = s[i + 1] - s[i]
		if diff < min_val:
			min_val = diff
	print(min_val)
t = int(input())
for test in range(t):
	solve()


from sys import *
t = int(stdin.readline())
while t > 0:
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	arr.sort()
	mn = abs(arr[1] - arr[0])
	for i in range(2, n):
		des = abs(arr[i] - arr[i - 1])
		mn = min(mn, des)
	print(mn)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	S = list(map(int, input().split()))
	S.sort()
	m = pow(10, 9)
	for i in range(len(S) - 1):
		m = min(m, S[i + 1] - S[i])
		if m == 0:
			break
	print(m)


import sys

def main():
	t = int(input())
	for _t in range(t):
		n = int(input())
		s = list(map(int, input().split()))
		dsave = 999
		for (i, x) in enumerate(s):
			for (j, y) in enumerate(s):
				if i == j:
					pass
				else:
					d = abs(x - y)
					if d < dsave:
						dsave = d
		print(dsave)
main()


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	minimum = 1000000
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < minimum:
			minimum = arr[i + 1] - arr[i]
	print(minimum)


for _ in range(int(input())):
	n = int(input())
	a = [int(a) for a in input().split()]
	a = sorted(a)
	s = set(a)
	l = []
	for i in range(n):
		for j in range(i + 1, n):
			l.append(abs(a[i] - a[j]))
	print(min(l))


def solve(n, s):
	s.sort()
	result = s[-1] - s[0]
	for i in range(n):
		for j in range(i + 1, n):
			result = min(result, s[j] - s[i])
	print(result)
	return
t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	solve(n, ar)


def diff():
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	k = 10 ** 10
	for j in range(1, len(l)):
		k = min(k, l[j] - l[j - 1])
	print(k)
t = int(input())
for i in range(t):
	diff()


t = int(input())
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	ar1 = set(ar)
	ar1 = sorted(ar1)
	if len(ar1) != len(ar):
		print(0)
	else:
		l = []
		for i in range(0, len(ar1) - 1):
			l.append(ar1[i + 1] - ar1[i])
		print(min(l))


k = int(input())
for j in range(k):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=False)
	real_minimum = 0
	minimum = 0
	for i in range(n - 1):
		real_minimum = a[i + 1] - a[i]
		if i == 0:
			minimum = real_minimum
		elif minimum >= real_minimum:
			minimum = real_minimum
	print(minimum)


tests = int(input())
for _ in range(tests):
	men = int(input())
	powers = list(map(int, input().split()))
	diff = 1000
	for i in range(len(powers)):
		if i != len(powers) - 1:
			for j in range(len(powers)):
				if i != j:
					if abs(powers[i] - powers[j]) < diff:
						diff = abs(powers[i] - powers[j])
	print(diff)


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	diff = 10000000000
	for i in range(n - 1):
		d = a[i + 1] - a[i]
		diff = min(d, diff)
	print(diff)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mi = 10000000
	for i in range(1, len(l)):
		if abs(l[i - 1] - l[i]) <= mi:
			mi = abs(l[i - 1] - l[i])
	print(mi)


def findMinDiff(arr, n):
	arr = sorted(arr)
	diff = 10 ** 20
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < diff:
			diff = arr[i + 1] - arr[i]
	return diff
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	x = list(map(int, input().split()))
	j = findMinDiff(x, n)
	print(j)


t = int(input())
for i in range(0, t):
	n = int(input())
	l1 = list()
	l1 = [int(x) for x in input().split()]
	l = list()
	l = sorted(l1)
	low = l[1] - l[0]
	for h in range(0, len(l) - 1):
		d = l[h + 1] - l[h]
		if d < low:
			low = d
	print(low)


t = int(input())
for xy in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	mins = 10 ** 5
	x = sorted(x)
	for ab in range(1, n):
		mins = min(x[ab] - x[ab - 1], mins)
	print(mins)


t = int(input())
while t > 0:
	n = int(input())
	s = sorted(list(map(int, input().split())))
	m = 9999999
	for i in range(0, n - 1):
		if abs(s[i + 1] - s[i]) < m:
			m = s[i + 1] - s[i]
	print(m)
	t -= 1


import sys
input = sys.stdin.readline
t = int(input())
for test in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = abs(s[1] - s[0])
	for i in range(len(s) - 1):
		temp = abs(s[i + 1] - s[i])
		if temp < ans:
			ans = temp
	print(ans)


lst1 = []
n = int(input())
for i in range(n):
	m = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	min = lst[1] - lst[0]
	for i in range(1, m - 1):
		diff = lst[i + 1] - lst[i]
		if diff < min:
			min = diff
	lst1.append(min)
for i in lst1:
	print(i)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if len(set(l)) < n:
		print(0)
	else:
		temp = sorted(l)
		diff = temp[1] - temp[0]
		for j in range(2, n):
			if temp[j] - temp[j - 1] < diff:
				diff = temp[j] - temp[j - 1]
		print(diff)


x = int(input())
for i in range(x):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	print(min((l[j + 1] - l[j] for j in range(n - 1))))


for i in range(int(input())):
	n = int(input())
	l = map(int, input().split())
	l = sorted(l)
	mini = 10 ** 9
	for i in range(1, n):
		mini = min(abs(l[i] - l[i - 1]), mini)
	print(mini)


t = int(input())
for i in range(t):
	n = int(input())
	a = map(int, input().split())
	a = list(a)
	a.sort()
	b = []
	for x in range(1, len(a)):
		b.append(abs(a[x - 1] - a[x]))
	print(min(b))


from math import *
import math

def r1(t):
	return t(input())

def r2(t):
	return [t(i) for i in input().split()]
for zzz in range(r1(int)):
	n = r1(int)
	s = r2(int)
	s.sort()
	ans = s[-1] - s[0]
	for i in range(n - 1):
		ans = min(ans, s[i + 1] - s[i])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	curr = a[1] - a[0]
	over = a[1] - a[0]
	for i in range(n - 1):
		b = a[i + 1] - a[i]
		curr = min(curr, b)
		over = min(over, curr)
	print(over)


t = int(input())
for i in range(t):
	n = int(input())
	l = input().split()
	l = [int(x) for x in l]
	l.sort()
	c = l[1] - l[0]
	for i in range(n - 1):
		c = min(c, abs(l[i + 1] - l[i]))
	print(c)


n = int(input())
while n != 0:
	x = input()
	l1 = list(map(int, input().split(' ')))
	mini = max(l1)
	for i in range(len(l1)):
		for j in l1[i + 1:]:
			diff = abs(l1[i] - j)
			if mini > diff:
				mini = diff
	print(mini)
	n = n - 1


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
t = INT()
while t != 0:
	n = INT()
	s = LIST()
	s.sort()
	mnDiff = INF
	for i in range(1, n):
		mnDiff = min(mnDiff, s[i] - s[i - 1])
	print(mnDiff)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(key=int)
	k = a[1] - a[0]
	for i in range(len(a) - 1):
		if k > a[i + 1] - a[i]:
			k = a[i + 1] - a[i]
	print(k, end='\n')


t = int(input())
for test in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	import sys
	ans = sys.maxsize
	for i in range(1, n):
		ans = min(ans, arr[i] - arr[i - 1])
	print(ans)


def min_diff(arr, n):
	mn = None
	for i in range(n - 1):
		if mn == None:
			mn = abs(arr[i] - arr[i + 1])
		elif abs(arr[i] - arr[i + 1]) < mn:
			mn = abs(arr[i] - arr[i + 1])
	return mn
t = int(input())
outputs = []
for i in range(t):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	outputs.append(min_diff(s, n))
for ans in outputs:
	print(ans)


lis_ans = []
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort()
	ans = 9999999
	for i in range(1, n):
		val = abs(max(lis[:i]) - min(lis[i:]))
		if val < ans:
			ans = val
	lis_ans.append(ans)
for i in lis_ans:
	print(i)


t = int(input())
for _ in range(t):
	n = int(input())
	S = list(map(int, input().split()))
	S.sort()
	D = []
	for i in range(n - 1):
		D.append(S[i + 1] - S[i])
	D.sort()
	print(D[0])


def solve():
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = 1000
	for i in range(1, n):
		ans = min(ans, s[i] - s[i - 1])
	print(ans)
t = int(input())
for _ in range(t):
	solve()


import math

def list_input():
	return list(map(int, input().split()))

def multiple_input():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list_input()
	a.sort(reverse=True)
	ans = 100000
	for i in range(1, n):
		diff = a[i - 1] - a[i]
		ans = min(diff, ans)
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = 10000
	for i in range(n - 1):
		if l[i + 1] - l[i] < m:
			m = l[i + 1] - l[i]
	print(m)


for _ in range(int(input())):
	n_size = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	res = []
	for i in range(len(arr) - 1):
		res.append(abs(arr[i] - arr[i + 1]))
	print(min(res))


for i in range(int(input())):
	x = int(input())
	arr = sorted(list(map(int, input().split())))
	min_ = float('inf')
	for i in range(1, len(arr)):
		min_ = min(min_, arr[i] - arr[i - 1])
	print(min_)


for r in range(int(input())):
	no = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = []
	for ra in range(no):
		ans.append(a[ra] - a[ra - 1])
	for each in range(len(ans)):
		if ans[each] < 0:
			ans[each] = -ans[each]
	ans = set(ans)
	print(min(ans))


def honest_coach(arr):
	new_arr = sorted(arr)
	diff = 1000
	for i in range(len(new_arr) - 1, -1, -1):
		if abs(new_arr[i] - new_arr[i - 1]) < diff:
			diff = abs(new_arr[i] - new_arr[i - 1])
	return diff
t = int(input())
for t_itr in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	result = honest_coach(arr)
	print(result)


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
for _ in range(vary(1)):
	n = vary(1)
	num = array_int()
	num.sort()
	ans = float('inf')
	for i in range(n - 1):
		ans = min(ans, num[i + 1] - num[i])
	print(ans)


for _ in range(int(input())):
	n = input()
	team = list(map(int, input().split()))
	m = max(team)
	for i in range(len(team)):
		for j in range(len(team)):
			if i != j:
				m = min(m, abs(team[i] - team[j]))
	print(m)


for i in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	res = l[1] - l[0]
	for j in range(1, a - 1):
		p = l[j + 1] - l[j]
		if p < res:
			res = p
	print(res)


min = -1

def fun(n, x):
	min = x[1] - x[0]
	for i in range(2, n):
		if x[i] - x[i - 1] < min:
			min = x[i] - x[i - 1]
	print(min)
t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	fun(n, x)


for ii in range(int(input())):
	n = int(input())
	arr = a = list(map(int, input().split()))
	arr = sorted(arr)
	diff = 10 ** 20
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < diff:
			diff = arr[i + 1] - arr[i]
	print(diff)


teams = int(input())
difs = []
menores = []
for team in range(teams):
	num = int(input())
	time = list(map(int, input().split()))
	time.sort()
	for i in range(len(time) - 1):
		dif = abs(time[i] - time[i + 1])
		difs.append(dif)
	menor = min(difs)
	menores.append(menor)
	difs = []
	time = []
for menor in menores:
	print(menor)


t = int(input())
for i in range(t):
	n = int(input())
	l = sorted([int(i) for i in input().split()])
	last = abs(l[0] - l[1])
	for i in range(n - 1):
		a = abs(l[i] - l[i + 1])
		if last >= a:
			last = a
	print(last)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	p = []
	for i in range(n - 1):
		p.append(l[i + 1] - l[i])
	if len(p) == 1:
		print(p[0])
	else:
		print(min(p))


def read_int():
	n = int(input())
	return n

def read_ints():
	ints = [int(x) for x in input().split(' ')]
	return ints

def solve(n, s):
	s.sort()
	min_diff = max(s)
	for i in range(1, len(s)):
		diff = s[i] - s[i - 1]
		min_diff = min(min_diff, diff)
	return min_diff
t = read_int()
for case in range(t):
	n = read_int()
	s = read_ints()
	sol = solve(n, s)
	print(sol)


for _ in range(int(input())):
	n = int(input())
	arr = []
	arr[0:n] = map(int, input().split())
	zz = []
	arr.sort()
	for i in range(n - 1):
		zz.append(arr[i + 1] - arr[i])
	print(min(zz))


t = int(input(''))
while t > 0:
	n = int(input(''))
	l = list(map(int, input().split()))
	l.sort()
	mini = abs(l[0] - l[1])
	for i in range(1, len(l) - 1):
		if abs(l[i] - l[i + 1]) < mini:
			mini = abs(l[i] - l[i + 1])
	print(mini)
	t -= 1


p = int(input())
for i in range(p):
	l = int(input())
	s = list(map(int, input().split()))
	mi = 99999999999
	for j in range(l):
		for t in range(l - 1):
			if s[t] > s[t + 1]:
				g = s[t]
				s[t] = s[t + 1]
				s[t + 1] = g
	for j in range(l - 1):
		if s[j + 1] - s[j] < mi:
			mi = s[j + 1] - s[j]
	print(mi)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	t = a[1] - a[0]
	for i in range(2, len(a)):
		b = a[i] - a[i - 1]
		if b < t:
			t = b
	print(t)


for _ in range(int(input())):
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort()
	minn = 12345678
	for i in range(1, n):
		minn = min(minn, ls[i] - ls[i - 1])
	print(minn)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans
from math import *
for _ in range(int(input())):
	li = []
	mini = 10000
	n = int(input())
	ath = list(map(int, input().split()))
	ath.sort()
	for i in range(n - 1):
		mini = min(mini, abs(ath[i] - ath[i + 1]))
	print(mini)


T = int(input())
for i in range(T):
	n = int(input())
	s = list(map(int, input().split()))
	s = sorted(s)
	min_d = max(s)
	for i in range(n - 1):
		d = s[i + 1] - s[i]
		if d < min_d:
			min_d = d
	print(min_d)


for i in range(int(input())):
	lines = int(input())
	strength = list(map(int, input().split()))
	strength.sort()
	print(min((abs(strength[i] - strength[i + 1]) for i in range(lines - 1))))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	x = 10000000000.0
	for i in range(n - 1):
		x = min(x, l[i + 1] - l[i])
	print(x)


t = int(input())
for i in range(t):
	input()
	numbers = list(map(int, input().split()))
	numbers.sort()
	minV = numbers[1] - numbers[0]
	for j in range(1, len(numbers)):
		if numbers[j] - numbers[j - 1] < minV:
			minV = numbers[j] - numbers[j - 1]
	print(minV)


t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	mn = 10 ** 10
	mni = 0
	mnii = 0
	for i in range(len(A) - 1):
		if A[i + 1] - A[i] < mn:
			mn = A[i + 1] - A[i]
			mni = i
			mnii = i + 1
	print(A[mnii] - A[mni])


import sys

def ans(L):
	L.sort()
	min = sys.maxsize
	for i in range(0, len(L) - 1):
		if abs(L[i + 1] - L[i]) <= min:
			min = abs(L[i + 1] - L[i])
	return min
n = int(input())
L = []
for i in range(n):
	x = int(input())
	A = [int(x) for x in input().split()]
	L.append(A)
for arr in L:
	print(ans(arr))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	minV = 99999
	for i in range(1, n):
		minV = min(minV, a[i] - a[i - 1])
	print(minV)


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	a.sort()
	ans = math.inf
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


t = int(input())
while t:
	n = int(input())
	l = []
	l = list(map(int, input().split()))
	dif2 = 99999999
	l.sort()
	for i in range(0, n):
		for j in range(n - 1, 0, -1):
			dif = l[j] - l[j - 1]
			dif2 = min(dif, dif2)
	print(dif2)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mini = max(l)
	for j in range(len(l) - 1):
		if l[j + 1] - l[j] < mini:
			mini = l[j + 1] - l[j]
	print(mini)


import sys
import math as mt
input = sys.stdin.buffer.readline
t = int(input())
for __ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	mini = 1000
	for i in range(n):
		for j in range(n):
			if j != i:
				mini = min(abs(l[i] - l[j]), mini)
	print(mini)


t = int(input())
for i in range(t):
	n = int(input())
	strength = list(map(int, input().split()))
	strength = strength[:n]
	strength.sort()
	minimum = 1000000007
	for i in range(1, n):
		minimum = min(abs(strength[i] - strength[i - 1]), minimum)
	print(minimum)


def min_dif(l):
	min_ = 1001
	l.sort()
	for i in range(len(l) - 1):
		if l[i + 1] - l[i] < min_:
			min_ = l[i + 1] - l[i]
	return min_
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	print(min_dif(A))


a = int(input())
for i in range(0, a):
	i = int(input())
	t = list(map(int, input().split()))
	t.sort()
	o = []
	for j in range(1, len(t)):
		o.append(t[j] - t[j - 1])
	print(min(o))


from math import *
from sys import stdin, stdout
input = stdin.buffer.readline
t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	m = 1000000000
	for i in range(1, n):
		x = a[i] - a[i - 1]
		if x < m:
			m = x
	print(m)
	t -= 1


def N():
	return int(input())

def NM():
	return map(int, input().split())

def L():
	return list(NM())

def LN(n):
	return [N() for i in range(n)]

def LL(n):
	return [L() for i in range(n)]
t = N()

def f():
	n = N()
	l = L()
	l.sort()
	ans = 10000
	for (i, j) in zip(l, l[1:]):
		ans = min(ans, j - i)
	print(ans)
for i in range(t):
	f()


import sys
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	minn = sys.maxsize
	for i in range(1, len(arr)):
		if arr[i] - arr[i - 1] < minn:
			minn = arr[i] - arr[i - 1]
	print(minn)


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		strength = list(map(int, input().split()))
		strength.sort()
		lowest_difference = strength[1] - strength[0]
		for k in range(1, len(strength) - 1):
			if strength[k + 1] - strength[k] < lowest_difference:
				lowest_difference = strength[k + 1] - strength[k]
		print(lowest_difference)
main()


for _ in range(int(input())):
	n = int(input())
	A = sorted([int(_) for _ in input().split()])
	X = []
	for _ in range(n - 1):
		X.append(A[_ + 1] - A[_])
	print(min(X))


for _ in range(int(input())):
	n = int(input())
	s = map(int, input().split())
	s = sorted(s)
	MIN = float('inf')
	for i in range(1, n):
		MIN = min(MIN, s[i] - s[i - 1])
	print(MIN)


nb_cases = int(input())
while nb_cases > 0:
	nb_cases -= 1
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	max_dist = abs(s[1] - s[0])
	for x in range(2, n):
		if abs(s[x] - s[x - 1]) < max_dist:
			max_dist = s[x] - s[x - 1]
	print(max_dist)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mini = -1
	for i in range(n - 1):
		if mini == -1 or a[i + 1] - a[i] < mini:
			mini = a[i + 1] - a[i]
	print(mini)


import sys
t = int(input())
for _ in range(t):
	n = int(input())
	st = list(map(int, input().split()))
	st.sort()
	mn = sys.maxsize
	for i in range(1, n):
		mn = min(mn, st[i] - st[i - 1])
	print(mn)


t = int(input())
for j in range(t):
	n = int(input())
	g = input().split()
	for i in range(n):
		g[i] = int(g[i])
	g.sort()
	minn = 10000
	for i in range(n - 1):
		if g[i + 1] - g[i] < minn and g[i + 1] - g[i] >= 0:
			minn = g[i + 1] - g[i]
	print(minn)


def main():
	n = int(input())
	ar = list(map(int, input().split()))
	if n == 2:
		print(abs(ar[0] - ar[1]))
		return
	ar.sort()
	a = b = 0
	_min = ar[n - 1] - ar[0]
	for i in range(n):
		for j in range(i + 1, n):
			_min = min(_min, ar[j] - ar[i])
	print(_min)
t = int(input())
for i in range(t):
	main()


m = int(input())
for i in range(m):
	input()
	inp = input().split()
	list = []
	diff = []
	for i in inp:
		list.append(int(i))
	list.sort()
	for i in range(1, len(list)):
		diff.append(list[i] - list[i - 1])
	diff.sort()
	print(diff[0])


import math
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	adjdiff = math.inf
	for i in range(1, n):
		adjdiff = min(adjdiff, s[i] - s[i - 1])
	print(adjdiff)


def f():
	input()
	a = [int(x) for x in input().split()]
	a.sort()
	ans = 10 ** 5
	for i in range(len(a) - 1):
		if a[i + 1] - a[i] < ans:
			ans = a[i + 1] - a[i]
	print(ans)
t = input()
for i in range(int(t)):
	f()


for _ in range(int(input())):
	_ = input()
	athletes = sorted(map(int, input().split()))
	difference = 1001
	for (a, b) in zip(athletes, athletes[1:]):
		if b - a < difference:
			difference = b - a
	print(difference)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	z = 0
	A = []
	B = []
	a.sort(reverse=True)
	for i in range(n - 1):
		A.append(a[i] - a[i + 1])
	print(a[A.index(min(A))] - a[A.index(min(A)) + 1])


from sys import maxsize
for _ in range(int(input())):
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort()
	ar = maxsize
	for i in range(n - 1):
		ar = min(ar, ls[i + 1] - ls[i])
	print(ar)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	a.sort()
	b = []
	for j in range(1, len(a)):
		b.append(abs(a[j - 1] - a[j]))
		if abs(a[j - 1] - a[j]) == 0:
			break
	print(min(b))


casos = int(input())
for i in range(casos):
	nAtl = int(input())
	atle = input()
	values = list(map(int, atle.split()))
	values.sort()
	res = values[1] - values[0]
	for j in range(nAtl - 1):
		res = min(res, values[j + 1] - values[j])
	print(res)


T = int(input())
for _ in range(T):
	N = int(input())
	S = [int(s) for s in input().split()]
	S.sort()
	ans = 10 ** 9
	for i in range(N - 1):
		ans = min(ans, S[i + 1] - S[i])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if len(arr) == 2:
		print(abs(arr[0] - arr[1]))
	else:
		extra = 1000
		arr.sort()
		for j in range(0, n - 1):
			diff = abs(arr[j] - arr[j + 1])
			if diff < extra:
				extra = diff
		print(extra)


t = int(input())
for _ in range(0, t):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	arr = sorted(arr)
	ans = 1002
	for i in range(1, len(arr)):
		ans = min(ans, abs(arr[i - 1] - arr[i]))
	print(ans)


import math
el = int(input())
for j in range(el):
	num = int(input())
	ar = []
	for i in input().split():
		ar.append(int(i))
	ar.sort()
	diff = abs(ar[0] - ar[1])
	for i in range(2, len(ar)):
		temp = abs(ar[i] - ar[i - 1])
		if temp < diff:
			diff = temp
			if diff == 0:
				break
	print(diff)


t = int(input())
output = []
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	temp = 99999999
	i = 0
	while i < n - 1:
		temp = min(temp, arr[i + 1] - arr[i])
		i += 1
	output.append(temp)
for i in output:
	print(i)


for x in range(int(input())):
	a = int(input())
	b = list(map(int, input().strip().split()[:a]))
	if len(b) == 2:
		print(abs(b[0] - b[1]))
	elif len(set(b)) != len(b):
		print(0)
	else:
		b.sort()
		c = 10 ** 4
		for x in range(len(b)):
			try:
				if abs(b[x] - b[x + 1]) < c:
					c = abs(b[x] - b[x + 1])
			except:
				continue
		print(c)


import sys
from collections import deque
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	minVal = s[-1]
	for i in range(0, n - 1):
		minVal = min(s[i + 1] - s[i], minVal)
	print(minVal)


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = []
	for i in range(1, n):
		ans.append(a[i] - a[i - 1])
	print(min(ans))


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = arr[0]
	s = []
	for i in range(len(arr)):
		for j in range(i + 1, len(arr)):
			s.append(abs(arr[i] - arr[j]))
	print(min(s))


def read_tokens():
	return input().strip().split(' ')

def read_ints():
	return [int(s) for s in read_tokens()]

def solve(arr: list) -> int:
	arr.sort()
	n = len(arr)
	cur_min = float('inf')
	for i in range(n - 1):
		diff = arr[i + 1] - arr[i]
		if diff < cur_min:
			cur_min = diff
	return cur_min
(T,) = read_ints()
for test in range(T):
	(n,) = read_ints()
	arr = read_ints()
	ans = solve(arr)
	print(ans)


test = int(input())
test_arr = []
for _ in range(test):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	diff = 1001
	for i in range(1, len(a)):
		new = abs(a[i - 1] - a[i])
		if new < diff:
			diff = new
	test_arr.append(diff)
for t in test_arr:
	print(t)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	t1 = []
	t2 = []
	a.sort()
	min_dist = 1000
	pos = 0
	for i in range(1, n):
		if abs(a[i] - a[i - 1]) < min_dist:
			min_dist = abs(a[i] - a[i - 1])
			pos = i
	print(min_dist)


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	t = a[1] - a[0]
	for i in range(1, n):
		if a[i] - a[i - 1] < t:
			t = a[i] - a[i - 1]
	print(t)


import os
import sys
import io
import math
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for t in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	answer = float('inf')
	for i in range(n - 1):
		answer = min(answer, abs(a[i] - a[i + 1]))
	print(answer)


q = int(input())
while q > 0:
	q -= 1
	n = int(input())
	mass = list(map(lambda x: int(x), input().split()))
	mass.sort()
	a = 10000000000.0
	for i in range(len(mass) - 1):
		a = min(a, mass[i + 1] - mass[i])
	print(a)


t = int(input())
for ti in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort()
	diffs = map(lambda i: arr[i + 1] - arr[i], range(n - 1))
	print(min(diffs))


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	m = 1 << 31
	for i in range(1, n):
		m = min(m, a[i] - a[i - 1])
	print(m)


import sys
from collections import Counter
input = sys.stdin.readline

def main():
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		ret = abs(arr[0] - arr[1])
		for i in range(n):
			for j in range(i + 1, n):
				num = abs(arr[i] - arr[j])
				if ret > num:
					ret = num
		print(ret)
main()


def solve(n, d):
	minInt = float('inf')
	d.sort()
	for i in range(n - 1):
		minInt = min(d[i + 1] - d[i], minInt)
	return minInt

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		d = input()
		d = [int(i) for i in d.split()]
		ans = solve(n, d)
		print(ans)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	line = list(map(int, input().split()))
	best = 1000
	line.sort()
	for i in range(len(line)):
		if i != len(line) - 1:
			get = abs(line[i] - line[i + 1])
			if get < best:
				best = get
	print(best)


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	ans = int(1e+18)
	for i in range(n - 1):
		ans = min(ans, arr[i + 1] - arr[i])
	print(ans)


import math
lst_of_pl = []
n = int(input())
for i in range(n):
	n1 = int(input())
	Pl = input()
	Pl = Pl.split()
	min1 = math.fabs(int(Pl[0]) - int(Pl[1]))
	for j in range(n1):
		for c in range(1, n1, 1):
			if c != j and math.fabs(int(Pl[j]) - int(Pl[c])) < min1:
				min1 = math.fabs(int(Pl[j]) - int(Pl[c]))
	lst_of_pl.append(int(min1))
for el in lst_of_pl:
	print(el)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mindif = 10000
	a.sort()
	for i in range(1, n):
		x = a[i] - a[i - 1]
		if x < mindif:
			mindif = x
	print(mindif)


for t in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	x = 1001
	for i in range(n - 1):
		if x > l[i + 1] - l[i]:
			x = l[i + 1] - l[i]
	print(x)


T = int(input())
(N, member) = ([], [])
for i in range(T):
	N.append(int(input()))
	member.append(list(map(int, input().split())))
	member[-1].sort()
for i in range(T):
	min_diff = 2000
	for j in range(1, N[i]):
		min_diff = min(member[i][j] - member[i][j - 1], min_diff)
	print(min_diff)


def main():
	k = int(input())
	for i in range(k):
		n = int(input())
		arr = list(map(int, input().split()))
		arr = sorted(arr)
		minn = arr[-1] - arr[0]
		tmp = -1
		for j in range(len(arr) - 1):
			if arr[j + 1] - arr[j] < minn:
				minn = arr[j + 1] - arr[j]
				tmp = j
		print(minn)
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(j) for j in input().split()]
	a.sort()
	diff = float('inf')
	for j in range(1, len(a)):
		diff = min(diff, a[j] - a[j - 1])
	print(diff)


n = int(input())
for x in range(n):
	m = int(input())
	array = list(map(int, input().split()[:m]))
	array.sort()
	ans = array[1] - array[0]
	for y in range(2, m):
		ans = min(ans, array[y] - array[y - 1])
	print(ans)


import math

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def inp():
	ls = list(map(int, input().split()))
	return ls
t = int(input())
for i in range(t):
	n = int(input())
	ls = inp()
	ls.sort()
	ans = []
	for j in range(n - 1):
		ans.append(ls[j + 1] - ls[j])
	print(min(ans))


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')

def main():
	for _ in range(iin()):
		n = iin()
		l = ain()
		l.sort()
		mini = MAX
		for i in range(n - 1):
			mini = min(mini, l[i + 1] - l[i])
		print(mini)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


no_of_lines = int(input())
lines = []
for i in range(no_of_lines):
	garbage = input()
	lines.append(input())
output = []
for i in lines:
	mindiff = 0
	num = [int(j) for j in i.split(' ')]
	num.sort()
	agernum = num[0]
	mindiff = abs(num[1] - num[0])
	for i in range(2, len(num)):
		thisdiff = abs(num[i] - num[i - 1])
		if thisdiff < mindiff:
			mindiff = thisdiff
	output.append(mindiff)
print('\n'.join((str(x) for x in output)))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = 9999999
	for i in range(1, n):
		if l[i] - l[i - 1] < a:
			a = l[i] - l[i - 1]
	print(a)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = float('INF')
	for i in range(n - 1):
		ans = min(ans, s[i + 1] - s[i])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	min_ = 100000000
	for j in range(0, n - 1):
		if abs(arr[j] - arr[j + 1]) < min_:
			min_ = abs(arr[j] - arr[j + 1])
	print(min_)


testcase = int(input())
for i in range(testcase):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	min1 = 10 ** 6
	for j in range(n - 1):
		if abs(li[j] - li[j + 1]) < min1:
			min1 = abs(li[j] - li[j + 1])
	print(min1)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	m = abs(a[0] - a[1])
	for i in range(1, n):
		if abs(a[i] - a[i - 1]) == 0:
			m = 0
			break
		if abs(a[i] - a[i - 1]) < m:
			m = abs(a[i] - a[i - 1])
	print(m)
t = int(input())
for i in range(t):
	solve()


tests = int(input())
while tests > 0:
	n = int(input())
	athletes = sorted([int(i) for i in input().split(' ')])
	smallestGap = 999999
	for (i, strength) in enumerate(athletes):
		if i == len(athletes) - 1:
			break
		diff = abs(strength - athletes[i + 1])
		if diff < smallestGap:
			smallestGap = diff
	print(smallestGap)
	tests = tests - 1


a = int(input())
for i in range(0, a):
	b = input()
	c = list(map(int, input().split()))
	c.sort()
	mini = c[1] - c[0]
	for j in range(2, len(c)):
		value = c[j] - c[j - 1]
		if value < mini:
			mini = value
	print(mini)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	mindiff = max(arr) - min(arr)
	arr = sorted(arr)
	for i in range(len(arr) - 1):
		if abs(arr[i + 1] - arr[i]) < mindiff:
			mindiff = abs(arr[i + 1] - arr[i])
	print(mindiff)


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	i = 1
	mn = 1000000
	while i < n:
		mn = min(mn, a[i] - a[i - 1])
		i += 1
	print(mn)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	min = 99999999999
	for i in range(1, n):
		if abs(a[i] - a[i - 1]) < min:
			min = abs(a[i] - a[i - 1])
	print(min)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	l.reverse()
	ans = 2147483647
	for i in range(n - 1, 0, -1):
		ans = min(ans, abs(l[i] - l[i - 1]))
	print(ans)


import math
for i in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	mx = float('inf')
	for i in range(1, n):
		x = l[i] - l[i - 1]
		mx = min(mx, x)
	print(mx)


import sys
t = int(input())
while t > 0:
	n = int(input())
	inp = list(map(int, input().split()))
	inp.sort()
	mini = inp[len(inp) - 1] - inp[len(inp) - 2]
	for i in range(len(inp) - 2, 0, -1):
		mini = min(inp[i] - inp[i - 1], mini)
	print(mini)
	t = t - 1


t = int(input())
for i in range(0, t):
	n = int(input())
	l = list(map(int, input().strip().split()))[:n]
	l = sorted(l)
	d = 10 ** 20
	for i in range(n - 1):
		if l[i + 1] - l[i] < d:
			d = l[i + 1] - l[i]
	print(d)


def solve(a, n):
	res = 10 ** 9 + 1
	for i in range(n - 1):
		res = min(res, a[i + 1] - a[i])
	return res

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = [int(i) for i in input().split()]
		print(solve(sorted(a), n))
main()


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	min = 1100000
	for i in range(1, n):
		if min > l[i] - l[i - 1]:
			min = l[i] - l[i - 1]
	print(min)


import sys
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	h = l[0]
	m = sys.maxsize
	for i in range(1, n):
		m = min(m, abs(h - l[i]))
		h = l[i]
	print(m)


number = int(input())
for iTask in range(number):
	n = int(input())
	inputStr = str(input())
	sArr = list(map(int, inputStr.split(' ')))
	if n == 2:
		print(max(sArr) - min(sArr))
	else:
		minDelta = 1001
		for i in range(n):
			for j in range(i + 1, n):
				delta = sArr[j] - sArr[i]
				if delta < 0:
					delta = -delta
				if delta < minDelta:
					minDelta = delta
				if minDelta == 0:
					break
			if minDelta == 0:
				break
		print(minDelta)


for _ in range(int(input())):
	n = int(input())
	num = list(map(int, input().split()))
	num.sort(reverse=True)
	i = 0
	diff = []
	while i <= n - 2:
		diff.append(num[i] - num[i + 1])
		i += 1
	print(min(diff))


tc = int(input())
for _ in range(tc):
	x = input()
	arr = list(map(int, input().split(' ')))
	arr.sort()
	ans = None
	for i in range(1, len(arr)):
		tmp = arr[i] - arr[i - 1]
		if ans is None or ans > tmp:
			ans = tmp
	print(ans)


t = int(input())
for z in range(t):
	(n, temp, flag) = (int(input()), [], True)
	list = [int(i) for i in input().split()]
	list.sort(reverse=True)
	for i in range(n):
		if list.count(list[i]) >= 2:
			print(0)
			flag = False
			break
	if flag:
		for i in range(1, n):
			temp.append(abs(list[i] - list[i - 1]))
		print(min(temp))


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s = sorted(s)
	high = 10 ** 4
	for i in range(n - 1):
		if s[i + 1] - s[i] < high:
			high = s[i + 1] - s[i]
	print(high)


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	p = sorted(ar)
	ans = 10000
	for i in range(1, len(p)):
		t = p[i] - p[i - 1]
		if ans > t:
			ans = t
	print(ans)


t = int(input())
for i in range(t):
	p = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 1000000000
	for j in range(p - 1):
		ans = min(ans, l[j + 1] - l[j])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort(reverse=True)
	min = ls[0] - ls[1]
	for i in range(1, n - 1):
		if ls[i] - ls[i + 1] < min:
			min = ls[i] - ls[i + 1]
	print(min)


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	a1 = []
	a2 = []
	for i in range(n):
		if i % 2 == 0:
			a1.append(arr[-1])
			arr.remove(arr[-1])
		else:
			a2.append(arr[-1])
			arr.remove(arr[-1])
	res = []
	for i in a1:
		for j in a2:
			res.append(abs(i - j))
	print(min(res))


n = int(input())
for i in range(0, n):
	y = int(input())
	x = list(map(int, input().split()))
	x.sort()
	temp = abs(x[0] - x[y - 1])
	for j in range(1, y):
		if abs(x[j - 1] - x[j]) <= temp:
			temp = abs(x[j - 1] - x[j])
	print(temp)


t = int(input())
for i in range(t):
	l = int(input())
	score = list(map(int, input().split()))
	smin = abs(score[0] - score[1])
	if l == 2:
		print(abs(score[0] - score[1]))
	else:
		for j in range(l):
			for k in range(l):
				if j != k:
					s = abs(score[j] - score[k])
					if smin > s:
						smin = s
		print(smin)


for _ in range(int(input())):
	l = int(input())
	l1 = list(map(int, input().split()))
	l1.sort()
	m = max(l1)
	for i in range(0, l - 1):
		if l1[i + 1] - l1[i] < m:
			m = l1[i + 1] - l1[i]
	print(m)


t = int(input())
for g in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 9999
	for i in range(1, n):
		if l[i] - l[i - 1] < ans:
			ans = l[i] - l[i - 1]
	print(ans)


try:
	t = int(input())
	i = 0
	while i < t:
		n = int(input())
		l = list(map(int, input().split()))
		l.sort()
		a = l[1] - l[0]
		for j in range(2, len(l)):
			if l[j] - l[j - 1] < a:
				a = l[j] - l[j - 1]
		print(a)
		i += 1
except:
	pass


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	i = 0
	least = 4e+18
	while i != len(l) - 1:
		if abs(l[i] - l[i + 1]) < least:
			least = abs(l[i] - l[i + 1])
		i += 1
	print(least)


for _ in range(int(input())):
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	print(min((s[i + 1] - s[i] for i in range(n - 1))))


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	comp = arr[1] - arr[0]
	for j in range(1, n - 1):
		temp = arr[j + 1] - arr[j]
		if temp < comp:
			comp = temp
	print(comp)


for i in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	print(min((lst[i + 1] - lst[i] for i in range(0, n - 1))))


t = int(input())
res = [None for _ in range(t)]
for i in range(t):
	n = int(input())
	s = [None for _ in range(n)]
	s = list(map(int, input().split()))
	s.sort()
	curr_diff = glob_diff = float('inf')
	for j in range(1, n):
		curr_diff = s[j] - s[j - 1]
		glob_diff = min(glob_diff, curr_diff)
	res[i] = glob_diff
for i in range(t):
	print(res[i])


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if n == 2:
		ans = abs(arr[0] - arr[1])
	else:
		m = float('inf')
		brr = sorted(arr)
		for j in range(1, n):
			magic = abs(brr[j - 1] - brr[j])
			if magic == 0:
				ans = 0
				break
			elif magic <= m:
				m = magic
				ans = m
	print(ans)


n = int(input())
for i in range(n):
	m = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	d = a[-1]
	for i in range(1, m):
		x = abs(a[i] - a[i - 1])
		if x < d:
			d = x
	print(d)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(k) for k in input().split()]
	a.sort(key=int)
	c = a[1] - a[0]
	for i in range(2, n):
		c = min(c, a[i] - a[i - 1])
	print(c)


from sys import stdin, stdout
for query in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = sorted([int(x) for x in stdin.readline().split()])
	high = s[1] - s[0]
	for ath in range(1, n):
		high = min(high, s[ath] - s[ath - 1])
	stdout.write(str(high) + '\n')


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a = sorted(a)
	sub = 99999999
	for i in range(len(a) - 1):
		sub = min(sub, a[i + 1] - a[i])
	print(sub)


t = int(input())
for _ in range(t):
	n = int(input())
	min1 = 999999999
	s = sorted(map(int, input().split()))
	for i in range(1, n):
		if int(s[i]) - int(s[i - 1]) <= min1:
			min1 = int(s[i]) - int(s[i - 1])
	print(min1)


from math import pow
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	min = l[1] - l[0]
	for i in range(1, n):
		diff = l[i] - l[i - 1]
		if min > diff:
			min = diff
	print(min)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	c = 1000000000000
	l.sort()
	for i in range(1, len(l)):
		if l[i] - l[i - 1] < c:
			c = l[i] - l[i - 1]
	print(c)


for _ in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	diff = []
	for i in range(1, n):
		diff.append(l[i] - l[i - 1])
	print(min(diff))


def helper(l, n):
	l.sort()
	diff = float('inf')
	for i in range(1, n):
		diff = min(diff, l[i] - l[i - 1])
	print(diff)
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	helper(l, n)


t = int(input())
for d in range(t):
	n = int(input())
	sp = [int(i) for i in input().split()]
	sp.sort()
	min_dif = sp[1] - sp[0]
	for i in range(2, n):
		if sp[i] - sp[i - 1] < min_dif:
			min_dif = sp[i] - sp[i - 1]
	print(min_dif)


a = int(input())
for i in range(a):
	n = int(input())
	b = sorted(list(map(int, input().split())))
	emp = set()
	for j in range(len(b) - 1):
		emp.add(b[j + 1] - b[j])
	print(min(emp))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	md = l[1] - l[0]
	idx = 0
	for i in range(1, n):
		md = min(md, l[i] - l[i - 1])
	print(md)


for _ in range(int(input())):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	res = s[n - 1] - s[0]
	for i in range(n):
		for j in range(i + 1, n):
			res = min(res, s[j] - s[i])
	print(res)


t = int(input())
for u in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mini = 10000000000
	for i in range(n - 1):
		if l[i + 1] - l[i] < mini:
			mini = l[i + 1] - l[i]
	print(mini)


t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(i) for i in input().split()]
	s.sort()
	ans = float('inf')
	for i in range(n - 1):
		ans = min(ans, abs(s[i] - s[i + 1]))
	print(ans)


t = int(input())
for k in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	arr.sort()
	diff = float('inf')
	for i in range(1, n):
		diff = min(diff, arr[i] - arr[i - 1])
	print(diff)


testcases = int(input())
for i in range(testcases):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	mins = 10 ** 4
	for i in range(1, n):
		if abs(arr[i] - arr[i - 1]) < mins:
			mins = abs(arr[i] - arr[i - 1])
	print(mins)


import sys, math, os
from io import BytesIO, IOBase
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1000000000.0) + 7

def main():
	for t in range(int(data())):
		n = int(data())
		s = mdata()
		s.sort()
		m = INF
		for i in range(n - 1):
			m = min(s[i + 1] - s[i], m)
		out(m)
main()


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(input())):
	n = l()[0]
	s = l()
	s.sort()
	x = n // 2
	if n == 2:
		print(s[1] - s[0])
		continue
	m = 1000000
	for i in range(1, n):
		m = min(m, s[i] - s[i - 1])
	print(m)


from sys import stdin, stdout

def find(arr, N):
	arr.sort()
	a = float('inf')
	for i in range(1, len(arr)):
		a = min(a, arr[i] - arr[i - 1])
	return a

def main():
	for _ in range(int(stdin.readline())):
		N = int(stdin.readline())
		arr = list(map(int, stdin.readline().split()))
		print(find(arr, N))
main()


def main():
	set_count = input()
	for i in range(int(set_count)):
		man_number = int(input())
		inputstr = input()
		streights = inputstr.split()
		streights = list(map(int, streights))
		streights.sort()
		min_dif = 99999999999999999
		for j in range(len(streights) - 1):
			first = streights[j]
			second = streights[j + 1]
			dif = second - first
			if dif < min_dif:
				min_dif = dif
		print(min_dif)
main()


import math
t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	dif = []
	for i in range(n):
		if i + 1 != n:
			dif.append(min([int(math.fabs(s[j] - s[i])) for j in range(i + 1, n)]))
	print(min(dif))


for i in range(int(input())):
	l = int(input())
	mi = 10000000000
	arr = [int(i) for i in input().split()]
	arr.sort()
	for j in range(l - 1):
		k = arr[j + 1] - arr[j]
		if k < mi:
			mi = k
	print(mi)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	pairwise_min = arr[-1]
	for i in range(1, len(arr)):
		if arr[i] - arr[i - 1] < pairwise_min:
			pairwise_min = arr[i] - arr[i - 1]
	print(pairwise_min)


n = int(input())
for _ in range(n):
	x = int(input())
	a = list(map(int, input().split()))
	a.sort()
	d = a[1] - a[0]
	for i in range(1, x - 1):
		if a[i + 1] - a[i] < d:
			d = a[i + 1] - a[i]
		if d == 0:
			break
	print(d)


for _ in range(int(input())):
	n = int(input())
	arr = sorted(map(int, input().split()))
	minor = 1001
	for i in range(1, n):
		if arr[i] - arr[i - 1] < minor:
			minor = arr[i] - arr[i - 1]
	print(minor)


def solve(s):
	s.sort()
	min = 1001
	for i in range(len(s) - 1):
		d = s[i + 1] - s[i]
		if min > d:
			min = d
	return min
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	print(solve(s))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = l[-1]
	for k in range(n - 1):
		s = l[k + 1] - l[k]
		if s < a:
			a = s
	print(a)


for _ in range(int(input())):
	n = int(input())
	A = list(sorted(map(int, input().split())))
	min = 104450120
	for j in range(n - 1):
		V = A[j + 1] - A[j]
		if V < min:
			min = V
	print(min)


cases = input()
for i in range(int(cases)):
	min_val = 100001
	input()
	numbers = input()
	array = [int(i) for i in numbers.split(' ')]
	for (idx, val) in enumerate(array):
		for val2 in array[idx + 1:]:
			comparation = abs(val - val2)
			if comparation < min_val:
				min_val = comparation
	print(min_val)


t = int(input())
for i in range(t):
	difference = 99999
	n = int(input())
	L = list(map(int, input().strip().split(' ')))
	for k in range(len(L)):
		for l in range(k, len(L)):
			if L[k] > L[l]:
				(L[k], L[l]) = (L[l], L[k])
	for k in range(1, len(L)):
		if L[k] - L[k - 1] < difference:
			difference = L[k] - L[k - 1]
	print(difference)


test_cases = int(input())
for i in range(test_cases):
	team_size = int(input())
	team_strength = list(map(int, input().split(' ')))
	team_strength.sort()
	print(min([abs(team_strength[i] - team_strength[i + 1]) for i in range(team_size - 1)]))


t = int(input())
for i in range(t):
	n = int(input())
	points = str(input()).split(' ')
	points = [int(x) for x in points]
	points.sort()
	min_diff = 10000
	for j in range(1, n):
		min_diff = min(points[j] - points[j - 1], min_diff)
	print(min_diff)


for i in range(int(input())):
	a = int(input())
	b = list(map(int, input().strip().split()))
	c = []
	b.sort()
	for j in range(1, len(b)):
		c.append(b[j] - b[j - 1])
	print(min(c))


import sys
import math
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(c) for c in input().split()]
	arr.sort()
	for i in range(0, len(arr) - 1):
		arr[i] = arr[i + 1] - arr[i]
	print(min(arr))


t = int(input())
ans = []
while t:
	n = int(input())
	a = list(map(int, input().split()))
	mina = -1
	ok = False
	for i in range(n):
		for j in range(i + 1, n):
			if abs(a[i] - a[j]) < mina or mina == -1:
				mina = abs(a[i] - a[j])
				if mina == 0:
					ok = True
					break
		if ok:
			break
	ans.append(mina)
	t -= 1
for i in range(len(ans)):
	print(ans[i])


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = 10 ** 9
	for i in range(n - 1):
		c = l[i + 1] - l[i]
		m = min(m, c)
	print(m)


import sys
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	a = get_array()
	b = sorted(a)
	flag = 0
	mini = b[n - 1] - b[n - 2]
	for i in range(n - 1):
		c = b[i + 1] - b[i]
		if c < mini:
			mini = c
	print(mini)


from sys import stdin
from math import ceil, sqrt
input = stdin.readline

def list_input():
	return list(map(int, input().split()))

def sep_input():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	l = list_input()
	l.sort()
	m = 2 ** 32
	for i in range(1, n):
		if l[i] - l[i - 1] < m:
			m = l[i] - l[i - 1]
	print(m)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	diff = max(a)
	for i in range(n):
		for j in range(n):
			if abs(a[i] - a[j]) < diff and i != j:
				diff = abs(a[i] - a[j])
	print(diff)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	if n == 2:
		print(abs(s[0] - s[1]))
	elif len(set(s)) != len(s):
		print(0)
	else:
		min = abs(s[0] - s[1])
		for i in range(n):
			for j in range(i + 1, n):
				if min > abs(s[i] - s[j]):
					min = abs(s[i] - s[j])
		print(min)


for p in range(0, int(input())):
	c = int(input())
	d = list(map(int, input().split(' ')))
	d.sort()
	min = 1000
	for i in range(0, c - 1):
		if abs(d[i] - d[i + 1]) < min:
			min = abs(d[i] - d[i + 1])
	print(min)


import math
t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	small = s[1] - s[0]
	for j in range(2, n):
		if s[j] - s[j - 1] <= small:
			small = s[j] - s[j - 1]
	print(small)


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def min_diff(strength):
	strength.sort()
	_min = None
	for i in range(len(strength) - 1):
		_diff = abs(strength[i] - strength[i + 1])
		_min = _diff if _min is None else min(_min, _diff)
	return _min
iters = int(input())
for i in range(iters):
	mens = int(input())
	strength = list(map(int, input().split()))
	print(min_diff(strength))


T = int(input())
for t in range(T):
	N = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	result = 10000
	for i in range(len(arr) - 1):
		result = min(result, arr[i + 1] - arr[i])
	print(result)


for _ in range(int(input())):
	N = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mina = 9999999999
	for i in range(1, N):
		mina = min(mina, a[i] - a[i - 1])
	print(mina)


test = int(input())
for i in range(test):
	n = int(input())
	sr = list(map(int, input().split()))
	sr.sort()
	min = sr[-1] - sr[0]
	for j in range(len(sr)):
		if abs(sr[j] - sr[j - 1]) < min:
			min = abs(sr[j] - sr[j - 1])
	print(min)


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = 1001
	for i in range(1, n):
		if l[i] - l[i - 1] < a:
			a = l[i] - l[i - 1]
	print(a)
	t -= 1


T = int(input())
for i in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	minv = 100000000000
	for i in range(n - 1):
		minv = min(minv, a[i + 1] - a[i])
	print(minv)


t = int(input())
for _ in range(t):
	n = int(input())
	L = [int(x) for x in input().split()]
	L = sorted(L)
	mindif = max(L)
	for i in range(n - 1):
		mindif = min(mindif, abs(L[i] - L[i + 1]))
	print(mindif)


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	ans = float('inf')
	n = int(stdin.readline())
	s = sorted(list(map(int, stdin.readline().split())))
	for i in range(n - 1):
		ans = min(ans, s[i + 1] - s[i])
	print(ans)


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	k = s[n - 1] - s[0]
	for i in range(n - 1):
		if k > s[i + 1] - s[i]:
			k = s[i + 1] - s[i]
	print(k)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	r = 999999
	for i in range(n - 1):
		if abs(l[i] - l[i + 1]) < r:
			r = abs(l[i] - l[i + 1])
	print(r)


def findMinDiff(arr, n):
	arr = sorted(arr)
	diff = 10 ** 20
	(ele_x, ele_y) = (arr[0], arr[1])
	for i in range(n - 1):
		if abs(arr[i + 1] - arr[i]) < diff:
			diff = abs(arr[i + 1] - arr[i])
			ele_x = arr[i]
			ele_y = arr[i + 1]
	return [diff, ele_x, ele_y]
tc = int(input())
for _ in range(tc):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = findMinDiff(arr, n)
	print(ans[0])


from math import inf
for _ in range(int(input().strip())):
	n = int(input().strip())
	strengths = list(map(int, input().split()))
	strengths.sort()
	m = inf
	for i in range(len(strengths) - 1):
		m = min(m, strengths[i + 1] - strengths[i])
	print(m)


test = int(input())
for i in range(test):
	n = int(input())
	a = [int(x) for x in input().split()]
	temp = 1001
	for i in range(n):
		for j in range(i + 1, n):
			temp = min(temp, abs(a[i] - a[j]))
	print(temp)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	min = 10000000
	for i in range(n):
		for j in range(i + 1, n):
			x = abs(l[i] - l[j])
			if min > x:
				min = x
			if min == 0:
				break
	print(min)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	s_i = list(map(int, s.split()))
	s_i.sort()
	min_diff = max(s_i)
	for k in range(n - 1):
		if s_i[k + 1] - s_i[k] < min_diff:
			min_diff = s_i[k + 1] - s_i[k]
	print(min_diff)


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
for _ in range(int(input())):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	diff = []
	for i in range(n - 1):
		diff.append(s[i + 1] - s[i])
	mini = float('inf')
	for i in range(n - 1):
		mini = min(mini, diff[i])
	print(mini)


import sys
t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mini = sys.maxsize
	for i in range(0, n - 1):
		mini = min(mini, abs(a[i] - a[i + 1]))
	print(mini)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	big = max(l)
	for j in range(n - 1):
		a = abs(l[-(j + 1)] - l[-(j + 2)])
		if a < big:
			big = a
	print(big)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	l = list(map(int, input().split()))
	ans = 1000000
	for i in range(n - 1):
		for j in range(i + 1, n):
			if abs(l[i] - l[j]) < ans:
				ans = abs(l[i] - l[j])
	print(ans)


for i in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	ans = min((abs(x[i] - x[i - 1]) for i in range(1, n)))
	print(ans)


for _ in range(int(input())):
	length = int(input())
	arr = sorted([int(i) for i in input().split()])
	dis = []
	for i in range(length - 1):
		dis.append(arr[i + 1] - arr[i])
	print(min(dis))


n = int(input())
for i in range(n):
	n_ath = int(input())
	ath_str = input().split()
	ath_str = sorted([int(x) for x in ath_str])
	pair_diff = [abs(ath_str[i] - ath_str[i - 1]) for i in range(1, len(ath_str))]
	print(min(pair_diff))


def function(n, nums):
	nums.sort()
	min1 = 10 ** 5
	for i in range(len(nums) - 1):
		c = abs(nums[i] - nums[i + 1])
		if c < min1:
			min1 = c
	return min1
t = int(input())
for k in range(t):
	n = int(input())
	nums = list(map(int, input().rstrip().split()))
	print(function(n, nums))


a = int(input())
for i in range(a):
	b = int(input())
	lis = list(map(int, input().split()))
	lis.sort()
	m = 100000
	k = 0
	for i in range(b - 1):
		if m > lis[i + 1] - lis[i]:
			m = lis[i + 1] - lis[i]
			if m == 0:
				k = 1
				print('0')
				break
	if k == 0:
		print(m)


t = int(input())
for we in range(t):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	d = abs(l[0] - l[1])
	for i in range(n - 1):
		if abs(l[i] - l[i + 1]) < d:
			d = abs(l[i] - l[i + 1])
	print(d)


for T in range(int(input())):
	N = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mn = max(arr) - min(arr)
	for i in range(N - 1):
		if abs(arr[i] - arr[i + 1]) < mn:
			mn = abs(arr[i] - arr[i + 1])
	print(mn)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	print(min([j - i for (i, j) in zip(a, a[1:])]))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return list(map(int, input().split()))

def solve(n, arr):
	arr = sorted(arr)
	_min = float('inf')
	for i in range(n - 1):
		_min = min(_min, abs(arr[i] - arr[i + 1]))
	return _min
t = inp()
for i in range(t):
	n = inp()
	arr = inlt()
	print(solve(n, arr))


def findMinDiff(arr, n):
	arr = sorted(arr)
	d = 10 ** 20
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < d:
			d = arr[i + 1] - arr[i]
	return d
answer = []
for i in range(int(input())):
	n = int(input())
	athlete = list(map(int, input().split()))
	athlete.sort()
	if len(athlete) != len(set(athlete)):
		s = 0
	else:
		s = findMinDiff(athlete, n)
	answer.append(s)
for i in range(len(answer)):
	print(answer[i])


def solve(s, n):
	s.sort()
	minDiff = max(s)
	for i in range(n - 1):
		if s[i + 1] - s[i] < minDiff:
			minDiff = s[i + 1] - s[i]
	print(minDiff)
t = int(input())
for test in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	solve(s, n)


for _ in range(int(input())):
	x = int(input())
	y = list(map(int, input().split()))
	y = sorted(y)
	min = 10 ** 6
	for i in range(len(y) - 1):
		diff = y[i + 1] - y[i]
		if min > diff:
			min = diff
		if min == 0:
			break
	print(min)


import math
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	min1 = 10000000
	for i in range(0, n):
		for j in range(i + 1, n):
			d = abs(l[i] - l[j])
			if d < min1:
				min1 = d
	print(min1)


import math
T = int(input())
for t in range(T):
	N = int(input())
	S = [int(_) for _ in input().split()]
	S = sorted(S)
	answer = math.inf
	for i in range(len(S) - 1):
		answer = min(answer, S[i + 1] - S[i])
	print(answer)


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	A.sort()
	B = []
	for i in range(N - 1):
		B.append(A[i + 1] - A[i])
	print(min(B))


lst2 = []
t = int(input())
dif = 100000
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	for i in range(n - 1):
		res = abs(lst[i] - lst[i + 1])
		if res < dif:
			dif = res
	lst2.append(dif)
	dif = 10000
for i in range(len(lst2)):
	print(lst2[i])


t = int(input())
for _ in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	sort_array = sorted(array)
	min_value = 1e+18
	for i in range(len(sort_array) - 1):
		check = sort_array[i + 1] - sort_array[i]
		if check <= min_value:
			min_value = check
	print(min_value)


I = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n,) = I()
	l = sorted(I())
	x = 10 ** 9
	for i in range(n - 1, 0, -1):
		x = min(x, l[i] - l[i - 1])
	print(x)


t = int(input())
for i in range(t):
	n = int(input())
	data = list(map(int, input().split()))
	data = sorted(data)
	ans = 1000000
	for j in range(1, n):
		curans = data[j] - data[j - 1]
		if curans < ans:
			ans = curans
	print(ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	pre = [abs(arr[i + 1] - arr[i]) for i in range(n - 1)]
	print(min(pre))


for _ in range(int(input())):
	n = int(input())
	s = map(int, input().split())
	s = sorted(s)
	c = []
	for i in range(0, n - 1):
		d = s[i + 1] - s[i]
		c.append(d)
	print(min(c))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = a
	d = []
	for i in range(len(a)):
		for j in range(len(a)):
			k = a[i] - b[j]
			if i != j and k >= 0:
				d.append(k)
	print(min(d))


n = int(input())
tests = [(int(input()), input().split()) for _ in range(n)]
for test in tests:
	lst = list(map(int, test[1]))
	lst.sort()
	diff = 1000
	for i in range(test[0] - 1):
		dif = lst[i + 1] - lst[i]
		if dif < diff:
			diff = dif
			if dif == 0:
				break
	print(diff)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort(reverse=True)
	tmp = s[0]
	diff_current = s[0]
	for val in s[1:]:
		diff_new = tmp - val
		tmp = val
		if diff_current > diff_new:
			diff_current = diff_new
	print(diff_current)


import sys
t = int(input())
while t:
	t -= 1
	_ = input()
	arr = [int(i) for i in input().split()]
	arr.sort()
	small = sys.maxsize
	prev = arr[0]
	for i in arr[1:]:
		if small > i - prev:
			small = i - prev
		prev = i
	print(small)


test = int(input())
for i in range(test):
	n = int(input())
	strength = list(map(int, input().split()))
	strength.sort()
	diff = list()
	val = 0
	for j in range(n):
		if j == n - 1:
			break
		val = int(strength[j + 1]) - int(strength[j])
		diff.append(val)
		if val == 0:
			break
	if val == 0:
		print(val)
	else:
		print(min(diff))


for _ in range(int(input())):
	l = int(input())
	Minimum = 100000000
	ls = sorted(list(map(int, input().split())))
	for i in range(len(ls) - 1):
		Minimum = min(Minimum, ls[i + 1] - ls[i])
	print(Minimum)


t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	md = s[n - 1] - s[0]
	for i in range(n - 1):
		md = min(md, s[i + 1] - s[i])
	print(md)


for i in range(int(input())):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	m = 1000000000.0
	for o in range(n - 1):
		if -s[o] + s[o + 1] <= m:
			m = -s[o] + s[o + 1]
	print(m)


t = int(input())
while t > 0:
	n = int(input())
	athletes = input().split(' ')
	athletes = [int(_) for _ in athletes]
	athletes = sorted(athletes)
	i = 0
	min = None
	while i < n - 1:
		if min == None or athletes[i + 1] - athletes[i] < min:
			min = athletes[i + 1] - athletes[i]
		i += 1
	print(min)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	mn = a[-1]
	for i in range(1, n):
		mn = min(a[i] - a[i - 1], mn)
	print(mn)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	min = abs(l[1] - l[0])
	for j in range(0, len(l) - 1):
		for k in range(j + 1, len(l)):
			if abs(l[k] - l[j]) < min:
				min = abs(l[k] - l[j])
	print(min)


for _ in range(int(input())):
	N = int(input())
	List = [int(x) for x in input().split()]
	List.sort()
	Min = List[1] - List[0]
	for i in range(1, N):
		Min = min(Min, List[i] - List[i - 1])
	print(Min)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	minima = float('inf')
	for i in range(len(s) - 1):
		hehe = s[i + 1] - s[i]
		if hehe < minima:
			minima = hehe
	print(int(minima))


t = int(input())
for _ in range(t):
	n = int(input())
	strength = list(map(int, input().split()))
	strength = sorted(strength)
	m = 1001
	for i in range(1, n):
		diff = strength[i] - strength[i - 1]
		if diff == 0:
			m = 0
			break
		m = min(diff, m)
	print(m)


t = int(input())

def honestCoach(arr):
	arr.sort()
	d = []
	for i in range(len(arr) - 1):
		d.append(arr[i + 1] - arr[i])
	return min(d)
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))[:n]
	print(honestCoach(arr))


def main():
	for _ in range(int(input())):
		s = int(input())
		t = [int(i) for i in input().split()]
		diff = max(t)
		t.sort()
		for i in range(1, s):
			if abs(t[i - 1] - t[i]) < diff:
				diff = abs(t[i - 1] - t[i])
		print(diff)
main()


t = int(input())
n = list()
a = list()
for i in range(t):
	n.append(int(input()))
	inpts = input()
	a.append(list(map(int, inpts.split(' '))))

def crit(a, b):
	return abs(a - b)
for i in range(t):
	if n[i] == 2:
		print(crit(a[i][0], a[i][1]))
	elif n[i] > len(set(a[i])):
		print(0)
	else:
		a[i] = sorted(a[i], reverse=True)
		difs = [abs(z - y) for (y, z) in zip(a[i][:-1], a[i][1:])]
		print(min(difs))


def process(members):
	members.sort()
	return min((members[i] - members[i - 1] for i in range(1, len(members))))
for _ in range(int(input())):
	input()
	print(process(list(map(int, input().split()))))


def solution(a):
	a.sort()
	dif = float('inf')
	for (idx, item) in enumerate(a):
		if idx != 0:
			dif = min(dif, item - a[idx - 1])
	print(dif)
inp = int(input())
for _ in range(inp):
	_ = input()
	a = list(map(int, input().split()))
	solution(a)


test = int(input())
for _ in range(test):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort(reverse=True)
	l = []
	for i in range(n - 1):
		l.append(s[i] - s[i + 1])
	print(min(l))


N = int(input())
for _ in range(N):
	n = int(input())
	arr = input().split(' ')
	arr = [int(a) for a in arr]
	arr = sorted(arr, reverse=True)
	d = float('inf')
	for i in range(1, n):
		d = min(d, arr[i - 1] - arr[i])
	print(d)


from collections import deque
t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted(map(int, input().split()))
	min_d = s[1] - s[0]
	for i in range(2, n):
		min_d = min(min_d, s[i] - s[i - 1])
	print(min_d)


n = int(input())
for i in range(n):
	a = int(input())
	b = input().split(' ')
	b = list(map(int, b))
	b = sorted(b, reverse=True)
	c = 1000000000
	for j in range(a - 1):
		if b[j] - b[j + 1] < c:
			c = b[j] - b[j + 1]
	print(c)


from itertools import combinations
for i in range(int(input())):
	a = input()
	a = list(map(int, input().split()))
	a.sort()
	maxval = 2147483648
	for i in range(0, len(a) - 1):
		(b, c) = (a[i], a[i + 1])
		if abs(b - c) < maxval:
			maxval = abs(b - c)
	print(maxval)


tt = int(input())
while tt:
	tt -= 1
	n = int(input())
	ll = list(map(int, input().split()))
	l = sorted(ll)
	m = []
	for i in range(len(l)):
		a = l[i] - l[i - 1]
		m.append(a)
	m.remove(m[0])
	print(min(m))


n = int(input())
for i in range(n):
	m = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = []
	for i in range(m - 1):
		x = abs(a[i] - a[i + 1])
		ans.append(x)
	q = min(ans)
	print(q)


import sys

def codeforces(arr):
	min = sys.maxsize
	arr.sort()
	for i in range(len(arr) - 1):
		if arr[i + 1] - arr[i] < min:
			min = arr[i + 1] - arr[i]
	return min
n = int(input())
for i in range(n):
	a = int(input())
	b = [int(ele) for ele in input().split()]
	res = codeforces(b)
	print(res)


import sys
t = int(input())
while t > 0:
	n = input()
	arr = [int(x) for x in input().split()]
	arr.sort()
	min_diff = sys.maxsize
	for i in range(len(arr) - 1):
		diff = arr[i + 1] - arr[i]
		min_diff = min(diff, min_diff)
		if min_diff == 0:
			break
	print(min_diff)
	t -= 1


import sys, math
I = sys.stdin.readline
ans = ''
for _ in range(int(I())):
	n = int(I())
	arr = sorted(list(map(int, I().split())))
	i = 0
	min_ = math.inf
	while i < n - 1:
		min_ = min(min_, arr[i + 1] - arr[i])
		i += 1
	ans += str(min_) + '\n'
print(ans)


t = int(input(''))
while t > 0:
	n = int(input(''))
	cm = list(map(int, input().split(' ')))
	mn = abs(cm[0] - cm[1])
	for i in range(n - 1):
		for j in range(i + 1, n):
			if abs(cm[i] - cm[j]) < mn:
				mn = abs(cm[i] - cm[j])
	print(mn)
	t -= 1


from sys import stdin
for t in range(int(input())):
	n = int(input())
	arr = list(map(int, stdin.readline().split()))
	arr.sort()
	mini = 9999999999999
	for i in range(1, n):
		if mini > arr[i] - arr[i - 1]:
			mini = arr[i] - arr[i - 1]
	print(mini)


for i in range(int(input())):
	n = int(input())
	s = sorted(map(int, input().split()[:n]))
	mn = max(s)
	m = s[0]
	for j in range(1, len(s)):
		if abs(s[j] - m) < mn:
			mn = abs(s[j] - m)
		m = s[j]
	print(mn)


for _ in range(int(input())):
	input()
	l = [int(i) for i in input().split()]
	l.sort()
	mindelta = 1000000000
	for i in range(len(l) - 1):
		mindelta = min(mindelta, l[i + 1] - l[i])
	print(mindelta)


t = int(input())
while t != 0:
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	f = l[1] - l[0]
	i = 2
	while f != 0 and i < len(l):
		x = l[i] - l[i - 1]
		if x < f:
			f = x
		i += 1
	print(f)
	t -= 1


T = int(input())
for i in range(1, T + 1):
	N = int(input())
	L = [int(x) for x in input().split()]
	min = max(L)
	L.sort()
	for j in range(0, len(L) - 1):
		if L[j + 1] - L[j] < min:
			min = L[j + 1] - L[j]
	print(min)


t = int(input())
for z in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mini = 1000
	for i in range(1, n):
		if l[i] - l[i - 1] < mini:
			mini = l[i] - l[i - 1]
	print(mini)


n = int(input())
l = []
for i in range(n):
	x = int(input())
	l.append(list(map(int, input().split())))
for i in l:
	res = []
	res = [sorted(i)[j + 1] - sorted(i)[j] for j in range(len(i) - 1)]
	print(min(res))


from sys import maxsize
test = int(input())
while test:
	test -= 1
	n = int(input())
	arr = input().split()
	arr = [int(i) for i in arr]
	arr = sorted(arr)
	minimum = maxsize
	i = 0
	while i < n - 1:
		if arr[i + 1] - arr[i] < minimum:
			minimum = arr[i + 1] - arr[i]
		i += 1
	print(minimum)


import sys
import collections as cc
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	l = I()
	l.sort()
	ans = 10 ** 9
	for i in range(n - 1):
		ans = min(ans, abs(l[i] - l[i + 1]))
	print(ans)


import sys
import math
from collections import defaultdict

def solve(test):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = sys.maxsize
	for i in range(n - 1):
		ans = min(ans, abs(s[i] - s[i + 1]))
	print(ans)
test_cases = int(input())
for t in range(1, test_cases + 1):
	solve(t)


t = int(input())
anss = [0] * t
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	anss[i] = min(map(lambda o: s[o] - s[o - 1], range(1, n)))
for ans in anss:
	print(ans)


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	s = list(map(int, input().strip().split()))[:n]
	s.sort()
	min_diff = s[n - 1] - s[0]
	for i in range(1, n):
		min_diff = min(s[i] - s[i - 1], min_diff)
	print(min_diff)


t = int(input())
while t > 0:
	n = int(input())
	s = [int(ele) for ele in input().split()]
	s.sort()
	min_diff = 999999
	for i in range(n - 1):
		min_diff = min(min_diff, abs(s[i] - s[i + 1]))
	print(min_diff)
	t -= 1


t = int(input())
while t > 0:
	n = int(input())
	lst = [int(x) for x in input().split()]
	lst.sort()
	minimum = None
	for i in range(len(lst) - 1):
		if minimum is None or minimum > lst[i + 1] - lst[i]:
			minimum = lst[i + 1] - lst[i]
	print(minimum)
	t = t - 1


import sys
import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
setrecursionlimit(2 ** 20)
M = 10 ** 9 + 7
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	s = list(map(int, stdin.readline().split()))
	s.sort()
	mn = 10 ** 6
	for i in range(n - 1):
		if s[i + 1] - s[i] < mn:
			mn = s[i + 1] - s[i]
	print(mn)


t = int(input())
while t:
	n = int(input())
	s = list(map(int, input().split(' ')))[:n]
	l = []
	for i in range(n - 1):
		for j in range(i + 1, n):
			l.append(abs(s[i] - s[j]))
	print(min(l))
	t = t - 1


def myFunc(l):
	l.sort()
	ans = 99999999
	for i in range(len(l) - 1):
		ans = min(ans, l[i + 1] - l[i])
	print(ans)
n = int(input())
for j in range(n):
	x = int(input())
	s = input().split(' ')
	l = [int(i) for i in s]
	myFunc(l)


a1 = int(input())
for i in range(a1):
	ath = int(input())
	n = list(map(int, input().split()))
	nn = sorted(n)
	vr = max(nn)
	for i in range(ath - 1):
		if vr > nn[i + 1] - nn[i]:
			vr = nn[i + 1] - nn[i]
	print(vr)


ans = []
t = int(input())
for ti in range(t):
	n = int(input())
	athleteList = list(map(int, input().split()))
	athleteList.sort()
	minDiff = athleteList[-1]
	for i in range(1, len(athleteList)):
		if minDiff > athleteList[i] - athleteList[i - 1]:
			minDiff = athleteList[i] - athleteList[i - 1]
	ans.append(minDiff)
for i in ans:
	print(i)


for i in range(0, int(input())):
	t = int(input())
	lista = [int(x) for x in input().split()]
	lista.sort()
	diferencia = lista[-1] - lista[0]
	j = 0
	while j < len(lista) - 1:
		if lista[j + 1] - lista[j] < diferencia:
			diferencia = lista[j + 1] - lista[j]
			j += 1
		else:
			j += 1
		if diferencia == 0:
			break
	print(diferencia)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	diff = 0
	v = []
	for i in range(1, n):
		diff = a[i] - a[i - 1]
		v.append(diff)
	v.sort()
	print(v[0])


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	m = float('inf')
	for i in range(1, n):
		m = min(m, s[i] - s[i - 1])
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	entrada = input()
	atlets = sorted(list(map(int, entrada.split())))
	best = -1
	for k in range(1, n):
		if best == -1:
			best = abs(atlets[k] - atlets[k - 1])
		elif abs(atlets[k] - atlets[k - 1]) < best:
			best = abs(atlets[k] - atlets[k - 1])
	print(best)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	count = 0
	min_count = a[1] - a[0]
	for i in range(1, n - 1):
		count = a[i + 1] - a[i]
		min_count = min(min_count, count)
		if min_count == 0:
			break
	print(min_count)


for _ in range(int(input())):
	m = 1000000
	v = 0
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	for i in range(n - 1):
		v = abs(l[i] - l[i + 1])
		if v < m:
			m = v
	print(m)


t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted([int(x) for x in input().split()])
	k = []
	for i in range(n):
		for j in range(i + 1, n):
			k.append(abs(s[j] - s[i]))
	print(min(k))


import sys
input = sys.stdin.readline
from collections import *
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = 10 ** 18
	for i in range(n - 1):
		ans = min(ans, s[i + 1] - s[i])
	print(ans)


t = int(input())
for turn in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())), reverse=True)
	if len(set(a)) < len(a):
		print(0)
		continue
	count = a[0]
	for i in range(len(a) - 1):
		if a[i] - a[i + 1] < count:
			count = a[i] - a[i + 1]
	print(count)


def st(nk):
	nk.sort()
	diff = []
	for i in range(len(nk) - 1):
		diff.append(nk[i + 1] - nk[i])
	return min(diff)
t = int(input())
ans = []
for i in range(t):
	n = int(input())
	nk = list(map(int, input().rstrip().split()))
	r = st(nk)
	ans.append(r)
for i in ans:
	print(i)


t = int(input())
nLst = []
athLst = []
for tt in range(t):
	n_i = int(input())
	nLst.append(n_i)
	ath = input().split()
	for x in range(len(ath)):
		ath[x] = int(ath[x])
	athLst.append(ath)
for i in range(t):
	athLst[i].sort()
	minDiff = 1001
	for j in range(1, nLst[i]):
		if athLst[i][j] - athLst[i][j - 1] < minDiff:
			minDiff = athLst[i][j] - athLst[i][j - 1]
	print(minDiff)


t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted([int(i) for i in input().split()])
	if n == 2:
		print(s[1] - s[0])
	else:
		print(min([s[i] - s[i - 1] for i in range(1, n)]))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	mini = 1000000000
	for i in range(len(li)):
		minis = 1000000000
		for j in range(len(li)):
			if i != j:
				minis = min(minis, abs(li[i] - li[j]))
		mini = min(minis, mini)
	print(mini)


for i in range(int(input())):
	a = input()
	x = [int(x) for x in input().split()]
	x.sort(reverse=True)
	mn = x[0] - x[1]
	for j in range(len(x) - 1):
		if x[j] - x[j + 1] < mn:
			mn = x[j] - x[j + 1]
	print(mn)


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
t = sInt()
for _ in range(t):
	n = sInt()
	a = lInt()
	a.sort()
	b = []
	for i in range(len(a) - 1):
		value = a[i + 1] - a[i]
		b.append(value)
	print(min(b))


t = int(input())
for i in range(t):
	n = int(input())
	s = [int(i) for i in input().split()]
	s.sort()
	a = []
	b = []
	res = 1000000000.0
	for k in range(1, len(s)):
		if s[k] - s[k - 1] < res:
			res = s[k] - s[k - 1]
	print(res)


for _ in range(int(input())):
	n = int(input())
	b = [int(x) for x in input().split()]
	if len(b) > len(list(set(b))):
		print(0)
	else:
		b = sorted(b)
		mini = 999999
		for i in range(len(b) - 1):
			if b[i + 1] - b[i] < mini:
				mini = b[i + 1] - b[i]
		print(mini)


T = int(input())
for i in range(T):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	an = 9999999999
	for i in range(0, n - 1):
		a = l[i + 1] - l[i]
		if a < an:
			an = a
	print(an)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	min_dist = arr[1] - arr[0]
	for j in range(n - 1):
		min_dist = min(min_dist, arr[j + 1] - arr[j])
	print(min_dist)


q = int(input())
for i in range(q):
	Min = 10000000
	n = int(input())
	a = list(map(int, input().split(' ')))
	a.sort()
	for j in range(n - 1):
		Min = min(Min, a[j + 1] - a[j])
	print(str(Min))


for _ in range(int(input())):
	n = int(input())
	arr = sorted(map(int, input().split()))
	print(min((abs(arr[i] - arr[i - 1]) for i in range(1, n))))


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ind = []
	for i in range(n - 1):
		sum = arr[i] - arr[i + 1]
		if sum < 0:
			sum = -sum
			ind.append(sum)
		ind.append(sum)
	min = ind[0]
	for j in ind:
		if j < min:
			min = j
	print(min)


import sys
for i in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, sys.stdin.readline().split())))
	diffArr = []
	for i in range(len(arr) - 1):
		diffArr.append(abs(arr[i] - arr[i + 1]))
	diffArr = sorted(diffArr)
	print(diffArr[0])


def sol(l):
	l = sorted(l)
	r = []
	for x in range(1, len(l)):
		r.append(l[x] - l[x - 1])
	return min(r)
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	v = sol(l)
	print(v)


for _ in range(int(input())):
	n = int(input())
	s = sorted(map(int, input().split()), reverse=True)
	mn = 100000.0
	for i in range(1, n):
		l1 = s[0:i]
		l2 = s[i:]
		if l1[-1] - l2[0] == 0:
			mn = 0
			break
		else:
			mn = min(l1[-1] - l2[0], mn)
	print(mn)


t = int(input())
while t > 0:
	b = int(input())
	l = list(map(int, input().split()))
	le = len(l)
	mi = 1000000
	for i in range(0, le - 1, 1):
		for j in range(i + 1, le, 1):
			mi = min(abs(l[i] - l[j]), mi)
	print(mi)
	t -= 1


sc = map(int, open(0).read().split())
ni = lambda : next(sc)
T = ni()
for _ in range(T):
	N = ni()
	S = sorted((ni() for _ in range(N)))
	print(min((b - a for (a, b) in zip(S, S[1:]))))


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	Query.append((N, A))
for (N, A) in Query:
	A.sort()
	ans = 10 ** 18
	for i in range(N - 1):
		ans = min(ans, A[i + 1] - A[i])
	print(ans)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	diff = l[1] - l[0]
	for i in range(2, n):
		if l[i] - l[i - 1] < diff:
			diff = l[i] - l[i - 1]
	print(diff)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	Min = 10 ** 5
	for i in range(n):
		for j in range(i + 1, n):
			Min = min(Min, a[j] - a[i])
	print(Min)


import sys
import math

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def printspx(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')

def printchk(*args):
	return print(*args, end=' \\ ')
MODPRIME = int(1000000000.0 + 7)
BABYMOD = 998244353
for _testcases_ in range(int(input())):
	n = int(input())
	li = get_array()
	li.sort()
	diff = float('inf')
	for i in range(len(li) - 1):
		diff = min(diff, li[i + 1] - li[i])
	print(diff)


T = int(input())
while T != 0:
	n = int(input())
	num = list(map(int, input().split()))
	ans = sorted(num)
	lowest = 999999
	for i in range(n - 1):
		if ans[i + 1] - ans[i] < lowest:
			lowest = ans[i + 1] - ans[i]
	print(lowest)
	T -= 1


t = int(input())
from math import inf
for _ in range(t):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	res = inf
	for i in range(1, n):
		res = min(res, arr[i] - arr[i - 1])
	print(res)


m = int(input())
for t in range(m):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mn = a[n - 1] - a[0]
	for i in range(n - 1):
		d = a[i + 1] - a[i]
		if d >= 0 and d < mn:
			mn = d
	print(mn)


t = int(input())
for _ in range(t):
	count = 0
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	l = s[n - 1]
	for i in range(1, n):
		l = min(s[i] - s[i - 1], l)
	print(l)


for _ in range(int(input())):
	n = int(input())
	ar = sorted(list(map(int, input().split())))
	s = []
	for i in range(len(ar) - 1):
		s.append(ar[i + 1] - ar[i])
	print(min(s))


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	if len(list(set(a))) != n:
		print('0')
		continue
	k = 1000
	f = 0
	for i in range(n - 1):
		j = a[i + 1] - a[i]
		if j == 1:
			print(j)
			f = 1
			break
		if j < k:
			k = j
	if f == 0:
		print(k)


for _ in range(int(input())):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	d = float('inf')
	for i in range(n - 1):
		a = s[i + 1] - s[i]
		if a < d:
			d = a
	print(d)


def solve(arr, n):
	maxi = arr[1] - arr[0]
	for i in range(n - 1):
		maxi = min(maxi, arr[i + 1] - arr[i])
	print(maxi)
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	solve(arr, n)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	coun = Counter(l)
	if min(coun.values()) > 1:
		print(0)
	else:
		minn = 999999
		sor = sorted(l)
		for i in range(1, len(sor)):
			m = sor[i] - sor[i - 1]
			if m < minn:
				minn = m
		print(minn)


def HonestCoach(n, s):
	s = sorted(s)
	distancia = max(s) - min(s)
	for i in range(n - 1):
		A = s[0:i + 1]
		B = s[i + 1:n]
		if abs(max(A) - min(B)) < distancia:
			distancia = abs(max(A) - min(B))
	return distancia
Lista = []
total = int(input())
for i in range(total * 2):
	All = [int(i) for i in input().split()]
	Lista.append(All)
for j in range(0, len(Lista), 2):
	print(HonestCoach(Lista[j][0], Lista[j + 1]))


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mi = 1000
	for i in range(1, n):
		if l[i] - l[i - 1] < mi:
			mi = l[i] - l[i - 1]
		if mi == 0:
			break
	print(mi)


a = int(input())
for _ in range(a):
	x = int(input())
	li = list(map(int, input().split()))
	min1 = abs(li[0] - li[1])
	for a in range(x - 1):
		for b in range(a + 1, x):
			if abs(li[a] - li[b]) < min1:
				min1 = abs(li[a] - li[b])
	print(min1)


t = int(input())
while t > 0:
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	i = n - 1
	mindiff = None
	while i > 0:
		cmin = lst[i] - lst[i - 1]
		if mindiff == None or mindiff > cmin:
			mindiff = cmin
		i -= 1
	print(mindiff)
	t -= 1


def function(list1):
	sortlist = sorted(list1)
	list2 = []
	for i in range(len(list1) - 1):
		diff = abs(sortlist[i] - sortlist[i + 1])
		list2.append(diff)
	return min(list2)
n = int(input())
for i in range(n):
	c = int(input())
	X = [int(x) for x in input().split()]
	print(function(X))


l = []

def find_min_diff(n, a):
	mins = max(a)
	for i in range(0, n - 1, 1):
		for j in range(i + 1, n):
			if abs(a[i] - a[j]) < mins:
				mins = abs(a[i] - a[j])
	return mins
for i in range(int(input())):
	c = find_min_diff(int(input()), list(map(int, input().split())))
	l.append(c)
for elm in l:
	print(elm)


import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		S = list(map(int, input().split()))
		S.sort()
		ans = INF
		for i in range(N - 1):
			ans = min(ans, S[i + 1] - S[i])
		print(ans)
main()


for j in range(int(input())):
	n = int(input())
	team = list(map(int, input().split()))
	team.sort()
	bar = 2000
	for i in range(1, n):
		if team[i] - team[i - 1] < bar:
			bar = team[i] - team[i - 1]
	print(bar)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	int_list = list(map(int, input().split()))
	int_list.sort()
	diff_list = [int_list[i + 1] - int_list[i] for i in range(n - 1)]
	print(min(diff_list))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	min_now = 100000000
	for i in range(1, n):
		min_now = min(abs(a[i] - a[i - 1]), min_now)
	print(min_now)


import sys
import math
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
t = int(input())
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 1000
	for i in range(n - 1):
		if a[i + 1] - a[i] < ans:
			ans = a[i + 1] - a[i]
	print(ans)


for i in range(int(input())):
	n = int(input())
	arr = [int(elem) for elem in input().split()]
	arr = sorted(arr)
	min_dist = arr[1] - arr[0]
	for i in range(2, n):
		if min_dist > arr[i] - arr[i - 1]:
			min_dist = arr[i] - arr[i - 1]
	print(min_dist)


for i in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	minn = int(10000000000)
	for j in range(1, n, 1):
		minn = min(minn, l[j] - l[j - 1])
	print(minn)


t = int(input())
for _ in range(t):
	n = int(input())
	aths = list(map(int, input().split()))
	aths.sort()
	mins = max(aths)
	for i in range(len(aths) - 1):
		mins = min(mins, aths[i + 1] - aths[i])
	print(mins)


from collections import defaultdict
from collections import OrderedDict
from collections import deque
import bisect
import math
import heapq
import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	diff = 10 ** 10
	for i in range(n - 1):
		diff = min(diff, abs(a[i] - a[i + 1]))
	print(diff)


import sys
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	ans = 1000000000.0
	for i in range(n):
		if i > 0:
			ans = min(ans, a[i] - a[i - 1])
	print(ans)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	mina = max(a)
	for i in range(n - 1):
		sub = abs(a[i] - a[i + 1])
		if sub < mina:
			mina = sub
	print(mina)


t = int(input())

def li():
	return list(map(int, input().split()))
for i in range(t):
	n = int(input())
	l = li()
	l.sort()
	minval = None
	for i in range(n - 1):
		if minval == None:
			minval = abs(l[i + 1] - l[i])
		else:
			minval = min(abs(l[i + 1] - l[i]), minval)
	print(minval)


import sys
t = sys.stdin.readline()
for i in range(int(t)):
	n = sys.stdin.readline()
	l1 = sys.stdin.readline().split()
	l = [int(i) for i in l1]
	l.sort()
	mini = min([abs(l[i] - l[i + 1]) for i in range(int(n) - 1)])
	sys.stdout.write(str(mini) + '\n')


t = int(input())
for i in range(t):
	n = int(input())
	vetor = list(map(int, input().split()))
	if len(vetor) != len(set(vetor)):
		print(0)
	else:
		vetor.sort()
		menor = max(vetor)
		for a in range(1, n):
			if vetor[a] - vetor[a - 1] < menor:
				menor = vetor[a] - vetor[a - 1]
				if menor == 1:
					break
		print(menor)


t = int(input())
for i in range(0, t):
	n = int(input())
	l = list(map(int, input().strip().split()))
	a = set(l)
	event = False
	for j in a:
		if l.count(j) > 1:
			event = True
	if event:
		print('0')
	else:
		b = sorted(l)
		c = []
		for j in range(1, n):
			c.append(b[j] - b[j - 1])
		print(str(min(c)))


for t in range(int(input())):
	n = int(input())
	ar = [int(s) for s in input().split()]
	ar.sort()
	ans = 1000
	for i in range(1, n):
		ans = min(ans, ar[i] - ar[i - 1])
	print(ans)


def main():
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort()
	print(min((arr[i + 1] - arr[i] for i in range(n - 1))))
for _ in range(int(input())):
	main()


t = int(input())
import math
for i in range(t):
	n = int(input())
	a = sorted(map(int, input().split()))
	m = math.inf
	for i in range(1, len(a)):
		m = min(m, a[i] - a[i - 1])
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	ans = 2000
	for j in range(n):
		for k in range(n):
			if j != k:
				sa = abs(s[j] - s[k])
				if sa < ans:
					ans = sa
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	minI = ar[1] - ar[0]
	for i in range(1, n - 1):
		diff = ar[i + 1] - ar[i]
		minI = min(minI, diff)
	print(minI)


q = int(input())
for i in range(q):
	l = int(input())
	arr = sorted(list(map(int, input().split())))
	mn = 100000
	for i in range(l - 1):
		mn = min(mn, arr[i + 1] - arr[i])
	print(mn)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		s = list(map(int, input().split()))
		a = sorted(s)
		ans = 10 ** 5
		for i in range(1, n):
			ans = min(abs(a[i] - a[i - 1]), ans)
		print(ans)
main()


t = int(input())
for i in range(t):
	b = int(input())
	l = [int(i) for i in input().split()]
	x = sorted(l)
	r = x[b - 1] - x[0]
	for j in range(b - 1):
		r = min(r, x[j + 1] - x[j])
	print(r)


n = int(input())
for x in range(n):
	throw = input()
	A = list(map(int, input().split()))
	A.sort()
	smallest = 10000000
	for x in range(len(A) - 1):
		smallest = min(smallest, A[x + 1] - A[x])
	print(smallest)


for _ in range(int(input())):
	qtd = int(input())
	l = sorted(list(map(int, input().split())))
	m = abs(l[0] - l[1])
	for i in range(1, qtd):
		m = min(m, abs(l[i] - l[i - 1]))
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	A = [int(x) for x in input().split()]
	mn = 5000
	for i in range(n):
		for j in range(i + 1, n):
			if abs(A[i] - A[j]) < mn:
				mn = abs(A[i] - A[j])
	print(mn)


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	l = sorted(l)
	m = l[-1]
	for i in range(n - 1):
		if l[i] == l[i + 1]:
			m = 0
			break
		elif l[i + 1] - l[i] < m:
			m = l[i + 1] - l[i]
	print(m)


t = int(input())
for tc in range(t):
	n = int(input())
	line = input().split()
	if n == 2:
		print(abs(int(line[0]) - int(line[1])))
		continue
	arr = []
	for i in range(n):
		arr.append(int(line[i]))
	arr.sort()
	low = 100000000
	for i in range(n - 1):
		if abs(arr[i] - arr[i + 1]) < low:
			low = abs(arr[i] - arr[i + 1])
	print(low)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	x = 10 ** 15
	for i in range(n - 1):
		x = min(x, a[i + 1] - a[i])
	print(x)


import sys
import math

def I():
	return int(sys.stdin.readline())

def IL():
	return list(map(int, sys.stdin.readline().strip().split()))

def ILS():
	return list(map(str, sys.stdin.readline().strip().split()))
t = I()
for i in range(t):
	n = I()
	l = IL()
	ans = None
	l.sort()
	for i in range(1, len(l)):
		if ans == None:
			ans = abs(l[i] - l[i - 1])
		else:
			ans = min(ans, abs(l[i] - l[i - 1]))
	print(ans)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math
import math
import time

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [-1 for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == -1:
			for i in range(p * p, n + 1, p):
				prime[i] = p
		p += 1
	for i in range(2, n + 1):
		if prime[i] == -1:
			prime[i] = i
	return prime

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, val, ans):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		v = val ** 5 - mid ** 5
		print(v)
		if v == ans:
			print('HOHOHOH')
			return mid
		elif v < ans:
			return binary(mid + 1, r, val, ans)
		else:
			return binary(l, mid - 1, val, ans)

def check(n):
	v = 1
	while n != 0:
		if n % 10 == 0 or n % 10 == 1:
			n = n // 10
		else:
			v = 0
			break
	return v

def stairs(n, m, val, c, l):
	if val > n:
		return 100000
	elif val == n:
		if l[val] != -1:
			return l[val]
		elif c % m == 0:
			l[val] = c
			return l[val]
		else:
			l[val] = 100000
			return l[val]
	else:
		l[val] = min(stairs(n, m, val + 1, c + 1, l), stairs(n, m, val + 2, c + 1, l))
		return l[val]

def fact(n):
	if n == 0 or n == 1:
		return 1
	else:
		return n * fact(n - 1)

def some(n):
	s = 0
	while n != 0:
		s += fact(n % 10)
		n //= 10
	return s

def bin(l, r, val, ll):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if ll[mid] == val:
			return mid
		elif ll[mid] > val:
			return bin(l, mid - 1, val, ll)
		else:
			return bin(mid + 1, r, val, ll)

def fn(n):
	c = -1
	for i in range(2, int(sqrt(n)) + 1):
		if n % 2 == 0:
			c = i
			break
	if c == -1:
		c = n
	return c

def check(n):
	val = 0
	while n != 0:
		if n % 10 > 1:
			val = -1
			break
		n = n // 10
	return val
t = int(input())
for i in range(t):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	mini = 100000
	for j in range(1, n):
		if mini > l[j] - l[j - 1]:
			mini = l[j] - l[j - 1]
	print(mini)


t = int(input())
res = []
for i in range(t):
	n = int(input())
	inp = input()
	arr = list(map(int, inp.split()))
	arr.sort()
	min_dif = float('+inf')
	for i in range(n - 1):
		if arr[i + 1] - arr[i] < min_dif:
			min_dif = arr[i + 1] - arr[i]
	res.append(min_dif)
for i in res:
	print(i)


t = int(input())
for w in range(t):
	n = int(input())
	l = sorted([int(i) for i in input().split()])
	d = l[n - 1] - l[0]
	for i in range(n - 1):
		d = min(d, l[i + 1] - l[i])
	print(d)


t = int(input())
for tc in range(t):
	n = int(input())
	A = sorted([int(_) for _ in input().split()])
	ans = min((abs(a - b) for (a, b) in zip(A, A[1:] + [10000])))
	print(ans)


t = int(input())
i = 0
while i < t:
	i += 1
	n = int(input())
	s = input()
	s = s.split()
	j = 0
	while j < n:
		s[j] = int(s[j])
		j += 1
	j = 0
	s.sort()
	j = 0
	diff = 10000000
	while j < n - 1:
		if int(s[j + 1]) - int(s[j]) < diff:
			diff = int(s[j + 1]) - int(s[j])
		j += 1
	print(diff)


from sys import stdin
input = stdin.readline
t = int(input().strip())
for _ in range(t):
	n = int(input().strip())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = float('inf')
	for i in range(n - 1):
		ans = min(ans, arr[i + 1] - arr[i])
	print(ans)


t = int(input())
for i in range(t):
	a = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	c = max(l) - min(l)
	for i in range(a - 1):
		if l[i] - l[i + 1] < c:
			c = l[i] - l[i + 1]
	print(c)


for _ in range(int(input())):
	am = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	m = 999999999
	for i in range(am - 1):
		m = min(arr[i + 1] - arr[i], m)
	print(m)


t = int(input())
for i in range(t):
	a = int(input())
	s = list(map(int, input().split()))
	s.sort()
	m = s[-1]
	for i in range(1, a):
		x = s[i] - s[i - 1]
		if x < m:
			m = x
		else:
			pass
	print(m)


I = lambda : list(map(int, input().split()))
t = I()[0]
while t:
	t -= 1
	n = I()[0]
	arr = I()
	arr.sort()
	ans = 10 ** 9
	for i in range(1, n):
		ans = min(ans, abs(arr[i] - arr[i - 1]))
	print(ans)


n = int(input())
for i in range(n):
	s = int(input())
	line = list(map(int, input().split()))
	line.sort()
	result: int = 0
	for j in range(1, len(line)):
		if j == 1:
			result = abs(line[j - 1] - line[j])
		elif abs(line[j - 1] - line[j]) < result:
			result = abs(line[j - 1] - line[j])
	print(result)


from sys import stdin
import math
a = int(stdin.readline())
for k in range(0, a):
	A = int(stdin.readline())
	B = stdin.readline().split()
	B.sort(key=int)
	MIN = int(B[1]) - int(B[0])
	for l in range(0, A - 1):
		MIN = min(int(B[l + 1]) - int(B[l]), MIN)
	print(MIN)


import math
t = int(input())
for u in range(t):
	n = int(input())
	a = list(sorted(list(map(int, input().split()))))
	diff = 99692196911
	for i in range(1, n):
		diff = min(diff, a[i] - a[i - 1])
	if diff == 99692196911:
		diff = a[0]
	print(diff)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	for j in range(n - 1):
		for k in range(j + 1, n):
			l1.append(abs(l[j] - l[k]))
			if abs(l[j] - l[k]) == 0:
				break
	print(min(l1))


import sys
input = sys.stdin.readline
import heapq
import copy
import math
import decimal
from decimal import *

class Node:

	def _init_(self, val):
		self.data = val
		self.left = None
		self.right = None

class fen_tree:

	def __init__(self, list):
		self.array = [0] + list
		for idx in range(1, len(self.array)):
			idx2 = idx + (idx & -idx)
			if idx2 < len(self.array):
				self.array[idx2] += self.array[idx]

	def prefix_query(self, idx):
		result = 0
		while idx:
			result += self.array[idx]
			idx -= idx & -idx
		return result

	def prints(self):
		print(self.array)
		return

	def range_query(self, from_idx, to_idx):
		return self.prefix_query(to_idx) - self.prefix_query(from_idx - 1)

	def update(self, idx, add):
		while idx < len(self.array):
			self.array[idx] += add
			idx += idx & -idx

def pre_sum(arr):
	p = [0]
	for i in arr:
		p.append(p[-1] + i)
	p.pop(0)
	return p

def pre_back(arr):
	p = [0]
	for i in arr:
		p.append(p[-1] + i)
	p.pop(0)
	return p

def bin_search(arr, l, r, val):
	if arr[r] <= val:
		return r + 1
	if r - l < 2:
		if arr[l] > val:
			return l
		else:
			return r
	mid = int((l + r) / 2)
	if arr[mid] <= val:
		return bin_search(arr, mid, r, val)
	else:
		return bin_search(arr, l, mid, val)

def search_leftmost(arr, val):

	def helper(arr, l, r, val):
		print(l, r)
		if arr[l] == val:
			return l
		if r - l <= 1:
			if arr[r] == val:
				return r
			else:
				print('not found')
				return
		mid = int((r + l) / 2)
		if arr[mid] >= val:
			return helper(arr, l, mid, val)
		else:
			return helper(arr, mid, r, val)
	return helper(arr, 0, len(arr) - 1, val)

def search_rightmost(arr, val):

	def helper(arr, l, r, val):
		print(l, r)
		if arr[r] == val:
			return r
		if r - l <= 1:
			if arr[l] == val:
				return r
			else:
				print('not found')
				return
		mid = int((r + l) / 2)
		if arr[mid] > val:
			return helper(arr, l, mid, val)
		else:
			return helper(arr, mid, r, val)
	return helper(arr, 0, len(arr) - 1, val)

def preorder_postorder(root, paths, parent, left, level):
	l = 0
	queue = [root]
	while queue != []:
		node = queue[-1]
		flag = 0
		for i in paths[node]:
			if i != parent[node] and level[i] == sys.maxsize:
				parent[i] = node
				level[i] = level[node] + 1
				flag = 1
				queue.append(i)
		if flag == 0:
			left[parent[node]] += 1 + left[node]
			queue.pop()
	return [parent, left, level]

def nCr(n, r, p):
	if r == 0:
		return 1
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = inp()
	mod = 998244353
	limit = 10 ** 18
	for test in range(tests):
		n = inp()
		a = inlt()
		a.sort()
		ans = sys.maxsize
		for i in range(1, n):
			ans = min(abs(a[i] - a[i - 1]), ans)
		print(ans)
main()


import sys
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def read():
	tc = 0
	if tc:
		input = sys.stdin.readline
	else:
		sys.stdin = open('input1.txt', 'r')
		sys.stdout = open('output1.txt', 'w')

def solve():
	for _ in range(ii()):
		n = ii()
		a = li()
		ans = 10000007
		a.sort()
		for i in range(1, n):
			ans = min(ans, a[i] - a[i - 1])
		print(ans)
solve()


from collections import Counter
import math
import sys
from bisect import bisect, bisect_left, bisect_right

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def mod():
	return 10 ** 9 + 7
for _ in range(int(input())):
	n = INT()
	arr = LIST()
	arr.sort()
	x = 10 ** 10
	for i in range(len(arr) - 1):
		x = min(x, abs(arr[i + 1] - arr[i]))
	print(x)


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	dif = ar[1] - ar[0]
	for i in range(1, n):
		dif = min(dif, abs(ar[i] - ar[i - 1]))
	print(dif)


t = int(input())
while t > 0:
	n = int(input())
	l1 = list(map(int, input().split()))[:n]
	l1.sort()
	diff = l1[1] - l1[0]
	for i in range(1, n - 1):
		diff1 = l1[i + 1] - l1[i]
		if diff1 < diff:
			diff = diff1
	print(diff)
	t = t - 1


def solve():
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	ans = []
	for i in range(n - 1):
		ans.append(lst[i + 1] - lst[i])
	print(min(ans))
t = int(input())
for i in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	s = [*map(int, input().split())]
	s.sort()
	print(min((y - x for (x, y) in zip(s, s[1:]))))


def main():
	import sys
	sys.setrecursionlimit(10 ** 6)
	input = sys.stdin.readline
	T = int(input())
	for t in range(T):
		n = int(input())
		si = sorted([int(x) for x in input().strip().split()])
		s_ = si[0]
		ans = 1000
		for s in si[1:]:
			ans = min(ans, abs(s_ - s))
			s_ = s
		print(ans)
main()


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = [int(o) for o in input().split()]
	a.sort()
	ans = a[-1]
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


for i in ' ' * int(input()):
	c = 0
	b = []
	n = int(input())
	a = [int(a) for a in input().split()]
	if len(set(a)) != len(a):
		print(0)
	else:
		a.sort()
		for i in range(1, len(a)):
			b.append(a[i] - a[i - 1])
			if 1 in b:
				print(1)
				c = 1
				break
		if c != 1:
			print(min(b))


t = int(input())
for i in range(t):
	size = int(input())
	x = input()
	li = list(map(int, x.split()))
	li.sort()
	min1 = 9999999999
	for i in range(size - 1):
		diff = abs(li[i] - li[i + 1])
		if diff < min1:
			min1 = diff
	print(min1)


import math
import sys
t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	print(min((s[i] - s[i - 1] for i in range(1, len(s)))))


for i in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	minn = 1
	for j in range(n):
		for k in range(j + 1, n):
			if j == 0 and k == 1:
				minn = abs(array[j] - array[k])
			else:
				my = abs(array[j] - array[k])
				if my < minn:
					minn = my
	print(minn)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		n = int(input())
		arry = list(map(int, input().split()))
		arry.sort()
		mindiff = float('inf')
		for i in range(n - 1):
			diff = abs(arry[i + 1] - arry[i])
			mindiff = min(mindiff, diff)
		yield mindiff
t = int(input())
ans = gift()
print(*ans, sep='\n')


test = int(input())
for t in range(test):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	min = abs(a[-1] - a[0])
	for i in range(1, len(a)):
		if min > abs(a[i] - a[i - 1]):
			min = abs(a[i] - a[i - 1])
	print(min)


a = int(input())
for i in range(a):
	b = int(input())
	mink = 1000
	c = input().split()
	for j in range(b):
		c[j] = int(c[j])
	c = sorted(c)
	for j in range(b - 1):
		if c[j + 1] - c[j] < mink:
			mink = c[j + 1] - c[j]
	print(mink)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = sorted(a)
	mi = 10000000000000
	for i in range(n - 1):
		mi = min(mi, b[i + 1] - b[i])
	print(mi)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mn = 1000000000.0
	for i in range(1, n):
		mn = min(l[i] - l[i - 1], mn)
	print(mn)


t = int(input())
for ti in range(t):
	n = input()
	l = input().split()
	mind = 10000
	mini = -1
	for i in range(int(n)):
		l[i] = int(l[i])
	l.sort()
	for (i, v) in enumerate(sorted(l)):
		if i == int(n) - 1:
			break
		diff = abs(int(v) - int(l[i + 1]))
		if diff < mind:
			mini = i
			mind = diff
	print(mind)


t = int(input())
for i in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	m = 999999999999999999999999999999999
	for i in range(n - 1):
		if min(m, a[i + 1] - a[i]) >= 0:
			m = min(m, a[i + 1] - a[i])
	print(m)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	mn = 10000000
	for i in range(n - 1):
		mn = min(mn, abs(arr[i + 1] - arr[i]))
	print(mn)


t = int(input())
for dud in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	smallest = 1000
	for idx in range(len(arr) - 1):
		x = abs(arr[idx] - arr[idx + 1])
		if x < smallest:
			smallest = x
	print(smallest)


for _ in range(int(input())):
	n = int(input())
	s = 1001
	a = [*map(int, input().split())]
	for i in range(0, n):
		for j in range(i + 1, n):
			if abs(a[i] - a[j]) < s:
				s = abs(a[i] - a[j])
	print(s)


cases = int(input())
for _ in range(cases):
	size = int(input())
	arr = list(map(int, input().split(' ')))
	arr.sort()
	diff = arr[1] - arr[0]
	prev = arr[0]
	for i in range(1, size):
		if arr[i] - prev < diff:
			diff = arr[i] - prev
		prev = arr[i]
	print(diff)


testing_mode = True
import sys, traceback
test_data = ''
final_output = ''

def input(input_format=0, multi=0):
	if multi > 0:
		return [input(input_format) for x in range(multi)]
	else:
		next_line = next(test_data, None).strip() if test_data else sys.stdin.readline()
		if input_format == 0:
			formatted_input = [next_line]
		elif input_format == 1:
			formatted_input = list(map(int, next_line.split()))
		elif input_format == 2:
			formatted_input = list(map(float, next_line.split()))
		elif input_format == 3:
			formatted_input = next_line.split()
		elif input_format == 4:
			formatted_input = (lambda x: [x[0], list(map(int, x[1:]))])(next_line.split())
		elif input_format == 5:
			formatted_input = (lambda x: [x[0], list(map(float, x[1:]))])(next_line.split())
		else:
			formatted_input = [next_line]
		return formatted_input if len(formatted_input) > 1 else formatted_input[0]

def log(*args):
	if testing_mode:
		print(*args)

def out(output_line, output_format=0, newline=True):
	global final_output
	formatted_output = ''
	if output_format == 0:
		formatted_output = str(output_line)
	elif output_format == 1:
		formatted_output = ' '.join(map(str, output_line))
	elif output_format == 1:
		formatted_output = '\n'.join(map(str, output_line))
	if testing_mode:
		final_output += formatted_output + '\n' * newline
	else:
		print(formatted_output, end='\n' if newline else '')
test_inputs = ['\n5\n5\n3 1 2 6 4\n6\n2 1 3 2 4 3\n4\n7 9 3 1\n2\n1 1000\n3\n100 150 200\n\n', '\n$$$\n', '\n$$$\n', '\n$$$\n']
test_outputs = ['\n1\n0\n2\n999\n50\n', '\n$$$\n', '\n$$$\n', '\n$$$\n']

def solve():
	n = input(1)
	for z in range(n):
		input()
		e = list(input(1))
		e.sort()
		m = 10 ** 10
		for i in range(len(e) - 1):
			m = min(m, abs(e[i] - e[i + 1]))
		out(m)
	return

def run_all(overwrite_testing=False):
	global testing_mode, final_output, test_data
	testing_mode = overwrite_testing and testing_mode
	if testing_mode:
		tests_failed = 0
		for (test_number, (test_in, test_out)) in enumerate(zip(test_inputs, test_outputs)):
			final_output = ''
			if test_in.lstrip()[:3] == '$$$':
				continue
			test_data = iter([i for i in test_in.split('\n') if i])
			print(f'Test Case #{test_number + 1}:')
			print('<' * 20)
			fail = False
			verdict = '\x1b[92m\x1b[1mPASS\x1b[0m'
			try:
				solve()
				final = final_output.rstrip('\n')
				raw_out = iter(map(str, final.split('\n'))) if final else iter(())
			except Exception:
				raw_out = ''
				fail = True
				print('\x1b[95m')
				traceback.print_exc()
				print('\x1b[0m')
			if raw_out:
				if test_out.lstrip()[:3] == '$$$':
					verdict = '\x1b[94m\x1b[1mSKIP\x1b[0m'
					print('\x1b[94m' + '\n'.join(list(raw_out)) + '\x1b[0m')
				else:
					for line_out in [i for i in test_out.split('\n') if i]:
						line_raw = next(raw_out, '% None %')
						if line_raw == line_out.strip():
							print(f'\x1b[92m{line_raw}\x1b[0m')
						else:
							print(f'\x1b[91m{line_raw}\x1b[0m')
							fail = True
					line_raw = next(raw_out, None)
					while line_raw:
						print(f'\x1b[91m{line_raw}\x1b[0m')
						line_raw = next(raw_out, None)
						fail = True
			print('>' * 20)
			if fail:
				verdict = '\x1b[91m\x1b[1mFAIL\x1b[0m'
				tests_failed += 1
			print(verdict + '\n')
		if tests_failed:
			print(f"\x1b[91m\x1b[1m{tests_failed} TEST{('S' if tests_failed > 1 else '')} FAILED!\x1b[0m")
		else:
			print(f'\x1b[92m\x1b[1mALL TESTS PASSED!\x1b[0m')
	else:
		test_data = False
		solve()
run_all(False)


t = int(input())
for _ in range(t):
	n = int(input())
	strs = [int(x) for x in input().split()]
	strs.sort()
	ans = 1000000000.0
	for i in range(len(strs) - 1):
		ans = min(ans, strs[i + 1] - strs[i])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	min_diff = float('inf')
	for i in range(len(arr)):
		for j in range(i + 1, len(arr)):
			if min_diff > abs(arr[i] - arr[j]):
				min_diff = abs(arr[i] - arr[j])
	print(min_diff)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	n = N()
	a = RLL()
	a.sort()
	res = a[-1]
	for i in range(1, n):
		res = min(res, a[i] - a[i - 1])
	print(res)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mini = 10000
	for i in range(1, len(arr)):
		if arr[i] - arr[i - 1] < mini:
			mini = arr[i] - arr[i - 1]
	print(mini)


for x in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	k = 10000
	m.sort()
	for i in range(0, n - 1):
		k = min(k, m[i + 1] - m[i])
	print(k)


for lo in range(int(input())):
	n = int(input())
	ls = [int(x) for x in input().split()]
	ls.sort(reverse=True)
	mn = 10000000
	for i in range(n - 1):
		mn = min(mn, ls[i] - ls[i + 1])
	print(mn)


def solve(strs):
	strs.sort()
	ans = 1001
	for i in range(1, len(strs)):
		ans = min(ans, strs[i] - strs[i - 1])
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	strs = [int(p) for p in input().split()]
	print(solve(strs))


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
import sys
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	count = inf
	for i in range(n - 1):
		count = min(count, l[i + 1] - l[i])
	print(count)


from itertools import combinations
for _ in range(int(input())):
	n = int(input())
	print(min([abs(t[0] - t[1]) for t in combinations(map(int, input().split()), 2)]))


T = int(input())
for t in range(T):
	n = int(input())
	s = sorted([int(i) for i in input().split()])
	mn = 1000
	for i in range(1, n):
		mn = min(mn, s[i] - s[i - 1])
	print(mn)


T = int(input())
while T:
	n = int(input())
	s = list(map(int, input().split()))
	diff = 1000
	s.sort()
	for i in range(n - 1):
		if abs(s[i] - s[i + 1]) < diff:
			diff = abs(s[i] - s[i + 1])
	print(diff)
	T -= 1


def solve1():
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort()
	ans = 1000
	for i in range(n - 1):
		ans = min(ans, arr[i + 1] - arr[i])
	print(ans)
for _ in range(int(input())):
	solve1()


t = int(input())
for j in range(t):
	k = int(input())
	x = sorted(list(map(int, input().split())))
	r = abs(x[0] - x[1])
	for i in range(1, k):
		if abs(x[i] - x[i - 1]) < r:
			r = abs(x[i] - x[i - 1])
	print(r)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	prev = A[0]
	result = 1001
	for i in range(1, n):
		if A[i] - prev < result:
			result = A[i] - prev
		if not result:
			break
		prev = A[i]
	print(result)


for n in range(int(input())):
	x = int(input())
	s = sorted(list(map(int, input().split())))
	res = 1000000000.0
	for n in range(1, x):
		res = min(res, s[n] - s[n - 1])
	print(res)


x = int(input())
for i in range(x):
	b = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = abs(a[1] - a[0])
	for j in range(1, b - 1):
		diff = abs(a[j] - a[j + 1])
		if diff <= ans:
			ans = diff
	print(ans)


import sys
tests = int(sys.stdin.readline().split()[0])
for test in range(tests):
	n = int(sys.stdin.readline().split()[0])
	s = [int(i) for i in sys.stdin.readline().split()]
	s.sort()
	B = [s.pop()]
	min_value = sys.maxsize
	while len(s) != 0:
		if min_value == 0:
			break
		if abs(max(s) - min(B)) < min_value:
			min_value = abs(max(s) - min(B))
		B.append(s.pop())
	print(min_value)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	x = sorted(list(map(int, input().split())))
	ans = x[1] - x[0]
	for i in range(1, len(x)):
		ans = min(ans, x[i] - x[i - 1])
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	d = 100000000000.0
	for i in range(n - 1):
		d = min(d, x[i + 1] - x[i])
	print(d)


for _ in range(int(input())):
	n = int(input())
	a = [int(s) for s in input().split()]
	a.sort()
	m = sum(a)
	for i in range(n - 1):
		if a[i + 1] - a[i] < m:
			m = a[i + 1] - a[i]
	print(m)


n = int(input())
for i in range(0, n):
	o = int(input())
	A = 10000000000000000000000
	p = input().rstrip().split(' ')
	p.sort(key=int)
	for j in range(1, len(p)):
		A = min(A, int(p[j]) - int(p[j - 1]))
	print(A)


t = int(input())
for i in range(0, t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	l = []
	for (x, y) in zip(a, a[1:]):
		l.append(abs(x - y))
	print(min(l))


t = int(input())
for tc in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = a[1] - a[0]
	for i in range(1, n):
		if a[i] - a[i - 1] < ans:
			ans = a[i] - a[i - 1]
	print(ans)


from sys import stdin

def getl():
	return stdin.readline().strip()

def geta():
	return getl().split()

def geti():
	return [int(x) for x in geta()]
(t,) = geti()
for _ in range(t):
	(n,) = geti()
	s = geti()
	s.sort()
	d = 1000
	for i in range(n - 1):
		diff = abs(s[i + 1] - s[i])
		if diff < d:
			d = diff
			if d == 0:
				break
	print(d)


def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
for _ in range(inin()):
	n = inin()
	l = ain()
	l.sort()
	diff = l[1] - l[0]
	for i in range(1, n):
		diff = min(l[i] - l[i - 1], diff)
	print(diff)


s = input()
while True:
	try:
		s = input()
		t = sorted(list(map(int, input().split(' '))))
		m = 100 * 100
		for i in range(len(t) - 1):
			m = min(m, abs(t[i] - t[i + 1]))
		print(m)
	except:
		break


def solution():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	min_gap = a[n - 1] - a[0]
	min_index = 0
	for i in range(len(a) - 1):
		min_index = i if a[i + 1] - a[i] < min_gap else min_index
		min_gap = a[min_index + 1] - a[min_index]
	print(min_gap)
T = int(input())
while T:
	solution()
	T -= 1


def solve():
	n = int(input())
	st = [int(s) for s in input().split()]
	st = sorted(st)
	if n == 2:
		print(st[1] - st[0])
		return
	minDiff = st[1] - st[0]
	for i in range(2, n):
		newDiff = st[i] - st[i - 1]
		if newDiff < minDiff:
			minDiff = newDiff
		if newDiff == 0:
			break
	print(minDiff)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = 1000
	d = 0
	a.sort()
	for j in range(len(a) - 1):
		d = abs(a[j] - a[j + 1])
		b = min(b, d)
		d = 0
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	i = 0
	minGap = 9999
	while i < len(l) - 1:
		g = l[i + 1] - l[i]
		minGap = min(g, minGap)
		i += 1
	print(minGap)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s = sorted(s)
	mins = 1000
	for i in range(1, n):
		mins = min(mins, s[i] - s[i - 1])
	print(mins)


import sys, heapq
from collections import *
from functools import lru_cache
sys.setrecursionlimit(10 ** 6)

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = list(map(int, input().split(' ')))
		arr.sort()
		res = float('inf')
		for i in range(1, n):
			res = min(res, arr[i] - arr[i - 1])
			if res == 0:
				break
		print(res)
main()


t = int(input())
for i in range(0, t):
	n = input()
	s = input()
	s = s.split(' ')
	min = 10000
	alr = False
	for i in s:
		if s.count(i) >= 2:
			print(0)
			alr = True
			break
		for c in s:
			if c != i:
				diff = int(c) - int(i)
				if diff < 0:
					diff *= -1
				elif diff < min:
					min = diff
	if not alr:
		print(min)


for _ in range(int(input())):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	m = 10 ** 3
	for i in range(n - 1):
		if s[i + 1] - s[i] < m:
			m = s[i + 1] - s[i]
	print(m)


for _ in range(int(input())):
	x = int(input())
	myList = list(map(int, input().split()))
	myList.sort()
	diff = 10000
	for i in range(1, x):
		if abs(myList[i - 1] - myList[i]) < diff:
			diff = abs(myList[i - 1] - myList[i])
	print(diff)


for i in range(int(input())):
	k = int(input())
	a = list(map(int, input().split()))
	a.sort()
	a = a[::-1]
	c = a[0] - a[1]
	for i in range(1, len(a) - 1):
		if a[i] - a[i + 1] < c:
			c = a[i] - a[i + 1]
	print(c)


def solve():
	n = int(input())
	sp = [int(i) for i in input().split()]
	sp.sort()
	minp = sp[1] - sp[0]
	for i in range(1, n - 1):
		minp = min(minp, sp[i + 1] - sp[i])
	print(minp)
for i in range(int(input())):
	solve()


INF = 1 << 60
t = int(input())
for i in range(t):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	ans = INF
	for j in range(1, n):
		ans = min(ans, abs(s[j] - s[j - 1]))
	print(ans)


import sys
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	m = sys.maxsize
	for i in range(1, n):
		m = min(m, s[i] - s[i - 1])
	print(m)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
for n in range(inp()):
	inp()
	ma = 10000
	c = sorted(inlt())
	for (ind, num) in enumerate(c[:len(c) - 1]):
		if ma > c[ind + 1] - num:
			ma = c[ind + 1] - num
	print(ma)


t = int(input())
while t:
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	answ = 10000
	for i in range(1, len(s)):
		answ = min(answ, s[i] - s[i - 1])
	print(answ)
	t -= 1


t = int(input())
arrs = []
mini = d = 0
for i in range(t):
	m = int(input())
	arr = list(map(int, input().split()[:m]))
	arrs.append(arr)
for j in arrs:
	j.sort()
	mini = j[1] - j[0]
	for k in range(0, len(j) - 1):
		if j[k + 1] - j[k] < mini:
			mini = j[k + 1] - j[k]
	print(mini)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	l = []
	for i in range(0, n - 1):
		l.append(a[i + 1] - a[i])
	print(min(l))


def ques2(n, s):
	s = sorted(s)
	diff = []
	for i in range(1, len(s)):
		x = s[i] - s[i - 1]
		diff.append(x)
	return min(diff)
t = int(input())
for i in range(t):
	n = int(input())
	s = [int(i) for i in input().split()]
	ans = ques2(n, s)
	print(ans)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	n = int(data())
	arr = l()
	arr.sort()
	answer = inf
	for i in range(1, n):
		answer = min(answer, arr[i] - arr[i - 1])
	out(answer)


for _ in range(int(input())):
	n = int(input())
	ar = [int(x) for x in input().split()]
	ar.sort()
	mx = 10000000000000
	for i in range(n - 1):
		mx = min(mx, ar[i + 1] - ar[i])
	print(mx)


t = int(input())
for i in range(t):
	u = 0
	z = 10 ** 15
	a = int(input())
	s = list(map(int, input().split()))
	s.sort()
	for p in range(len(s) - 1):
		u = s[p + 1] - s[p]
		z = min(u, z)
	print(z)


for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	m = float('inf')
	for i in range(1, n):
		m = min(m, arr[i] - arr[i - 1])
	print(m)


t = int(input())
for _ in range(t):
	n = int(input())
	l1 = [int(i) for i in input().split()]
	s = set(l1)
	l2 = list(s)
	if len(l2) < len(l1):
		print(0)
	else:
		l1.sort()
		l3 = [abs(l1[i] - l1[i + 1]) for i in range(0, n - 1)]
		print(min(l3))


T = int(input())
for i in range(T):
	n = int(input())
	S = list(map(int, input().split()))
	S.sort()
	ans = 99999999
	for j in range(n - 1):
		x = abs(S[j] - S[j + 1])
		ans = min(ans, x)
	print(ans)


t = int(input())
for i in range(0, t):
	n = int(input())
	q = [int(x) for x in input().split()]
	A = []
	B = []
	min1 = float('inf')
	q1 = sorted(q)
	for i in range(0, len(q1) - 1):
		if min1 > q1[i + 1] - q1[i]:
			a = q1[i + 1]
			b = q1[i]
			min1 = q1[i + 1] - q1[i]
	A.append(a)
	B.append(b)
	q1.remove(a)
	q1.remove(b)
	for i in range(0, len(q1) - 1):
		if q1[i] < a:
			A.append(q1[i])
		else:
			B.append(q1[i])
	A = sorted(A)
	B = sorted(B)
	print(min1)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	mini = 10000
	for i in range(len(a) - 1):
		for j in range(0, len(a)):
			if i == j:
				continue
			if abs(a[i] - a[j]) < mini:
				mini = abs(a[i] - a[j])
	print(mini)
	t = t - 1


t = int(input())
for i in range(t):
	n = int(input())
	S = list(map(int, input().split()))
	S.sort()
	ans = float('inf')
	for j in range(n - 1):
		ans = min(ans, S[j + 1] - S[j])
		if ans == 0:
			print(0)
			break
	else:
		print(ans)


t = int(input())
while t != 0:
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	min = 10000000
	for i in range(1, n):
		f = abs(x[i] - x[i - 1])
		if f < min:
			min = f
	print(min)
	t -= 1


author = 'DarshanMohan'
import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(MAP())

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def add(a, b, c):
	res = a + b
	if res >= c:
		return res - c
	else:
		return res

def mod(a, b, c):
	res = a * b
	if res >= c:
		return res % c
	else:
		return res

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	w = a // gcd(a, b)
	return w * b
for _ in range(INT()):
	n = INT()
	s = LIST()
	temp = 999999999
	for i in range(n - 1):
		for j in range(i + 1, n):
			if abs(s[j] - s[i]) <= temp:
				temp = abs(s[j] - s[i])
	print(temp)


t = input()
for i in range(0, int(t)):
	ins = []
	diff = 999
	n = input()
	ins = list(map(int, input().split()))
	for w in range(0, len(ins)):
		for z in range(0, len(ins)):
			if w == z:
				continue
			if ins[w] - ins[z] >= 0 and ins[w] - ins[z] < diff:
				diff = ins[w] - ins[z]
	print(diff)


for _ in range(int(input())):
	a = []
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(0, n):
		for j in range(1, n):
			if i - j != 0 and j > i:
				diff = l[j] - l[i]
				a.append(abs(diff))
	print(min(a))


for t in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	res = []
	for i in range(1, len(s)):
		res.append(s[i] - s[i - 1])
	print(min(res))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	diff = float('inf')
	a.sort()
	for i in range(1, n):
		diff = min(diff, a[i] - a[i - 1])
	print(diff)


import sys
from collections import defaultdict
input = sys.stdin.readline

def print_result(l):
	return print(' '.join(map(str, l)))

def timer(function):
	import time

	def wrapper(*args, **kwargs):
		t1 = time.time()
		val = function()
		t2 = time.time()
		print('Executed \\{}\\ in {:.2f} seconds.'.format(function.__name__, t2 - t1))
		return val
	return wrapper

def solve():
	n = int(input())
	arr = [int(x) for x in input().split(' ')]
	res = float('inf')
	for i in range(len(arr)):
		for j in range(i + 1, len(arr)):
			res = min(res, abs(arr[i] - arr[j]))
	print(res)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	m = 20000
	list1.sort()
	for i in range(1, n):
		x = list1[i] - list1[i - 1]
		if x < m:
			m = x
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	lista = input().split()
	for j in range(n):
		lista[j] = int(lista[j])
	lista.sort()
	dif = lista[1] - lista[0]
	for j in range(0, n - 1):
		if lista[j + 1] - lista[j] < dif:
			dif = lista[j + 1] - lista[j]
	print(dif)


def fun(n, arr):
	arr.sort()
	mini = pow(10, 10)
	for i in range(0, n - 1):
		temp1 = arr[0:i + 1]
		temp2 = arr[i + 1:]
		a = max(temp1)
		b = min(temp2)
		if abs(a - b) < mini:
			mini = abs(a - b)
	return mini
for i in range(0, int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	print(fun(n, arr))


from math import *
from collections import *
from operator import itemgetter
import bisect
i = lambda : input()
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
I = lambda : list(map(int, input().split()))
chrIdx = lambda x: ord(x) - 96
idxChr = lambda x: chr(96 + x)
t = ii()
for _ in range(t):
	n = ii()
	a = iia()
	a.sort()
	m = 1000000
	for i in range(n - 1):
		if a[i + 1] - a[i] < m:
			m = a[i + 1] - a[i]
	print(m)


num_test_case = int(input())
i = 1
list_output = []
while num_test_case > 0:
	num_of_athletes = int(input())
	list_strength = input().split()
	for i in range(0, len(list_strength)):
		list_strength[i] = int(list_strength[i])
	list_strength.sort()
	k = 1
	min = abs(list_strength[0] - list_strength[1])
	while k < len(list_strength) - 1:
		temp = abs(list_strength[k] - list_strength[k + 1])
		if temp < min:
			min = temp
		k += 1
	list_output.append(min)
	num_of_athletes -= 1
	num_test_case -= 1
	i += 1
for i in list_output:
	print(i)


t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(i) for i in input().split()]
	s.sort()
	m = 1000
	for i in range(1, len(s)):
		dif = s[i] - s[i - 1]
		if dif < m:
			m = dif
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	diff = [arr[i + 1] - arr[i] for i in range(n - 1)]
	print(min(diff))


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().strip().split()]
	minn = float('inf')
	a.sort()
	for i in range(len(a) - 1):
		if abs(a[i] - a[i + 1]) < minn:
			minn = abs(a[i] - a[i + 1])
	print(minn)


import sys
import math
input = sys.stdin.readline

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()

def lower_letters():
	lowercase = [chr(i) for i in range(97, 97 + 26)]
	return lowercase

def upper_letters():
	uppercase = [chr(i) for i in range(65, 65 + 26)]
	return uppercase
for i in range(int(input())):
	n = int(input())
	arr = sorted(int_array())[::-1]
	mini = 10000000000.0
	for i in range(n - 1):
		if arr[i] - arr[i + 1] < mini:
			mini = arr[i] - arr[i + 1]
			no1 = arr[i]
			no2 = arr[i + 1]
	print(no1 - no2)


from sys import stdin

def main():
	t = int(stdin.readline())
	while t > 0:
		n = int(stdin.readline())
		a = stdin.readline().strip().split(' ')
		for i in range(n):
			a[i] = int(a[i])
		print(find_min_diff(a))
		t = t - 1
	stdin.close()

def find_min_diff(a: list):
	a.sort()
	n = len(a)
	min = a[1] - a[0]
	for i in range(n - 1):
		diff = a[i + 1] - a[i]
		if diff < min:
			min = diff
	return min
main()


t = int(input())
for case in range(t):
	n = int(input())
	s = [int(a) for a in input().split(' ')]
	s.sort()
	print(min([s[ii + 1] - s[ii] for ii in range(n - 1)]))


t = int(input())
for i in range(t):
	n = int(input())
	athletes = list(map(int, input().split()))
	athletes.sort()
	res = 9999999999999999999
	for i in range(1, len(athletes)):
		res = min(res, abs(athletes[i - 1] - athletes[i]))
	print(res)


t = int(input())
for i in range(t):
	m = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = sorted(set(a))
	mini = 1000
	if a != b:
		print(0)
	else:
		for i in range(1, m):
			if mini > a[i] - a[i - 1]:
				mini = a[i] - a[i - 1]
		print(mini)


def ans(l):
	l1 = []
	l2 = []
	n = len(l)
	m = 1000000
	for i in range(0, n - 1, 1):
		for j in range(i + 1, n, 1):
			m = min(abs(l[i] - l[j]), m)
	print(m)
t = int(input())
while t > 0:
	a = int(input())
	l = list(map(int, input().split()))
	if a == 2:
		print(abs(l[0] - l[1]))
	else:
		ans(l)
	t -= 1


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = 10 ** 6
	for i in range(n - 1, 0, -1):
		ans = min(ans, s[i] - s[i - 1])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	lis = sorted(map(int, input().split()))
	mm = 1000000000
	for i in range(1, n):
		if lis[i] - lis[i - 1] < mm:
			mm = lis[i] - lis[i - 1]
	print(mm)


t = int(input())
for i in range(t):
	a = int(input())
	s = list(map(int, input().split()))
	s.sort()
	p = []
	for j in range(a - 1):
		z = s[j + 1] - s[j]
		p.append(z)
		p.sort()
	print(p[0])


t = int(input())
for q in range(t):
	n = int(input())
	ch = input()
	L = [int(i) for i in ch.split()]
	L.sort()
	minn = 1001
	for i in range(1, n):
		minn = min(minn, L[i] - L[i - 1])
	print(minn)


def answer(ary):
	diff_ary = [0] * (len(ary) - 1)
	for i in range(len(ary) - 1):
		diff_ary[i] = ary[i + 1] - ary[i]
	return min(diff_ary)

def main():
	t = int(input())
	n = [0] * t
	arry = [None] * t
	for j in range(t):
		n[j] = int(input())
		arry[j] = [int(i) for i in input().split()]
		arry[j].sort()
	for j in range(t):
		print(answer(arry[j]))
main()


for x in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	mn = l[-1] - l[0]
	for i in range(n - 1):
		mn = min(mn, l[i + 1] - l[i])
		if mn == 0:
			break
	print(mn)


def Israil_Cse(n, arr):
	arr.sort()
	l = len(arr)
	min = arr[l - 1]
	for i in range(n - 1):
		dif = arr[i + 1] - arr[i]
		if dif <= min:
			min = dif
	return min
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(Israil_Cse(n, arr))


for _ in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	mod = sorted(nums)
	chk = True
	for i in range(n - 1):
		if mod[i] == mod[i + 1]:
			print(0)
			chk = False
			break
	if chk:
		min_diff = abs(mod[0] - mod[1])
		for i in range(n - 1):
			diff = abs(mod[i] - mod[i + 1])
			min_diff = min(diff, min_diff)
		print(min_diff)


def main():
	T = int(input())
	for i in range(1, T + 1):
		n = int(input())
		s = [int(_) for _ in input().split(' ')]
		s.sort()
		min_diff = 1000000000000
		for (j, v) in enumerate(s[1:]):
			diff = v - s[j]
			if diff < min_diff:
				min_diff = diff
		print(min_diff)
main()


import sys

def arr():
	return list(map(int, input().split()))
input = sys.stdin.readline
for _ in range(int(input())):
	N = int(input())
	L = arr()
	L.sort()
	mi = float('inf')
	for i in range(1, N):
		mi = min(mi, L[i] - L[i - 1])
	print(mi)


t = int(input())
for i in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	k = sorted(li, reverse=True)
	mini = 99999999
	for j in range(n - 1):
		p = k[j] - k[j + 1]
		if abs(p) < mini:
			mini = abs(p)
	print(mini)


tests = int(input())
for i in range(tests):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	maxv = 100000000
	for i in range(n - 1):
		val = arr[i + 1] - arr[i]
		if val < maxv:
			maxv = val
	print(maxv)


t = int(input())
for case in range(t):
	n = int(input())
	List = [int(j) for j in input().split(' ')]
	List.sort()
	List_1 = []
	for i in range(n - 1):
		List_1.append(List[i + 1] - List[i])
	print(min(List_1))


def b():
	for _ in range(int(input())):
		tamanho_time = int(input())
		atletas = list(map(int, input().split()))
		atletas.sort()
		resultado = atletas[tamanho_time - 1] - atletas[0]
		for i in range(len(atletas) - 1):
			resultado = min(resultado, atletas[i + 1] - atletas[i])
		print(resultado)
b()


from collections import Counter, defaultdict, deque
from math import *
import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	d = 10 ** 9
	for i in range(n - 1):
		d = min(d, arr[i + 1] - arr[i])
	print(d)
tt = int(input())
for test in range(tt):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	res = max(a)
	a.sort()
	for i in range(1, len(a)):
		res = min(res, a[i] - a[i - 1])
	if res >= 0:
		print(res)


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().strip().split()))
	min = 100001
	arr = sorted(arr)
	for i in range(1, len(arr)):
		if abs(arr[i] - arr[i - 1]) < min:
			min = abs(arr[i] - arr[i - 1])
	print(min)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	mn = 100000
	for i in range(1, n):
		if lst[i] - lst[i - 1] < mn:
			mn = lst[i] - lst[i - 1]
	print(mn)


for k in range(int(input())):
	a = int(input())
	t = list(map(int, input().split()))
	t.sort()
	if len(set(t)) < a:
		print(0)
	else:
		p = t[-1]
		for k in range(1, a):
			if t[k] - t[k - 1] < p:
				p = t[k] - t[k - 1]
		print(p)


for mda in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	ans = 1000000000.0
	for i in range(n - 1):
		if a[i + 1] - a[i] < ans:
			ans = a[i + 1] - a[i]
	print(ans)


import sys
data = sys.stdin.readlines()
filtered_data = []
for i in range(2, len(data)):
	if i % 2 == 0:
		filtered_data += [data[i].strip().split()]

def ascending(list):
	answer = [] + [int(list[-1])]
	list2 = list[:-1]
	for item in list2:
		i = 0
		inserted = int(item)
		while i <= len(answer) - 1 and inserted > answer[i]:
			i += 1
		answer[i:i] = [inserted]
	return answer
differences = []
for item in filtered_data:
	output = ascending(item)
	differences = []
	for i in range(len(output) - 1):
		differences += [output[i + 1] - output[i]]
	print(min(differences))


t = int(input())
for _ in range(0, t):
	n = int(input())
	s = input().split()
	for i in range(0, n):
		s[i] = int(s[i])
	s.sort()
	min = abs(s[0] - s[1])
	for i in range(1, n - 1):
		if min > abs(s[i] - s[i + 1]):
			min = abs(s[i] - s[i + 1])
	print(min)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	team = list(map(int, sys.stdin.readline().split()))
	team.sort()
	mini = 10 ** 5
	for i in range(1, n):
		mini = min(mini, team[i] - team[i - 1])
	print(mini)


for _ in range(int(input())):
	a = int(input())
	arr = list(map(int, input().split()))
	x = []
	arr.sort()
	for i in range(1, a):
		x.append(arr[i] - arr[i - 1])
	print(min(x))


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	s.reverse()
	emp = []
	for i in range(len(s) - 1):
		emp.append(s[i] - s[i + 1])
	print(min(emp))


n = int(input())
l = []
for i in range(n):
	a = int(input())
	b = list(map(int, input().split()))
	l.append(b)
d = []
for i in l:
	i.sort()
	x = i[1] - i[0]
	for j in range(1, len(i) - 1):
		if i[j + 1] - i[j] < x:
			x = i[j + 1] - i[j]
	d.append(x)
for i in d:
	print(i)


for __ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 10 ** 18
	for i in range(0, n - 1):
		ans = min(ans, abs(a[i] - a[i + 1]))
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	s = sorted(a)
	mi = 10000000000.0
	for i in range(n - 1):
		if mi > s[i + 1] - s[i]:
			mi = s[i + 1] - s[i]
	print(mi)


for _ in range(int(input())):
	n = int(input())
	L = list(map(int, input().split()))
	L.sort()
	M = []
	for i in range(1, n):
		M.append(L[i] - L[i - 1])
	print(min(M))


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	x = 1000
	y = 0
	for i in range(n - 1):
		if abs(li[i] - li[i + 1]) < x:
			x = abs(li[i] - li[i + 1])
			y = i
	if n == 2:
		print(abs(li[0] - li[1]))
	else:
		print(abs(max(li[:y + 1]) - min(li[y + 1:])))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = arr[-1]
	for i in range(n - 1, 0, -1):
		ans = min(ans, abs(arr[i] - arr[i - 1]))
	print(ans)


import math
t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	minn = math.inf
	for i in range(1, n):
		diff = arr[i] - arr[i - 1]
		minn = min(minn, diff)
	print(minn)
	t -= 1


import math
import random
mod = 1000000007
r1 = lambda : int(input())
rm = lambda : map(int, input().split())
rls = lambda : list(rm())
test = r1()
while test:
	test -= 1
	n = r1()
	ls = rls()
	ls.sort()
	ans = 1000000000
	for i in range(1, n):
		if abs(ls[i - 1] - ls[i]) < ans:
			ans = abs(ls[i - 1] - ls[i])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	dif = l[1] - l[0]
	for j in range(n - 1):
		if l[j + 1] - l[j] < dif:
			dif = l[j + 1] - l[j]
	print(dif)


for xyz in range(0, int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = []
	for i in range(0, n - 1):
		d.append(l[i + 1] - l[i])
	d.sort()
	print(d[0])


from sys import stdin
inp = stdin.readline
t = int(inp().strip())
while t:
	t -= 1
	n = int(inp().strip())
	s = [int(k) for k in inp().strip().split()]
	s = sorted(s)
	lowestDiff = s[1] - s[0]
	for i in range(n - 1):
		if s[i + 1] - s[i] < lowestDiff:
			lowestDiff = s[i + 1] - s[i]
			if lowestDiff == 0:
				break
	print(lowestDiff)


n = int(input())
for w in range(n):
	a = int(input())
	l = list(map(int, input().split()))
	diff = 10000000
	l.sort()
	for i in range(a - 1):
		if l[i + 1] - l[i] < diff:
			diff = l[i + 1] - l[i]
	print(diff)


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = 10 ** 9
	for i in range(1, n):
		ans = min(ans, s[i] - s[i - 1])
	print(ans)


t = int(input())
for ti in range(t):
	n = int(input())
	a = input().split()
	a = [int(i) for i in a]
	a.sort()
	less = 1000000000000
	for i in range(n - 1):
		if a[i + 1] - a[i] < less:
			less = a[i + 1] - a[i]
	print(less)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	dif = 1001
	s.sort()
	for i in range(n - 1):
		dif = min(dif, s[i + 1] - s[i])
		if dif == 0:
			break
	print(dif)


t = int(input())
for i in range(t):
	arr = []
	n = int(input())
	arr = [int(j) for j in input().split()]
	arr.sort(reverse=True)
	for i in range(len(arr) - 1):
		arr[i] = arr[i] - arr[i + 1]
	arr[i + 1] = arr[i]
	print(min(arr))


t = input()
for i in range(int(t)):
	z = input()
	n = int(z)
	aa = [int(a) for a in input().split()]
	aa.sort()
	ans = aa[1] - aa[0]
	for j in range(n - 1):
		ans = min(ans, abs(aa[j + 1] - aa[j]))
	print(ans)


def read_int():
	return int(input())

def read_string_array():
	for s in input().split():
		yield s

def read_int_array():
	for s in read_string_array():
		yield int(s)

def read_line():
	return input()

def solve(s):
	s = sorted(s)
	min_diff = abs(s[0] - s[1])
	for i in range(len(s) - 1):
		a = abs(s[i] - s[i + 1])
		if a < min_diff:
			min_diff = a
	return min_diff
T = read_int()
for _ in range(T):
	N = read_int()
	S = read_int_array()
	print(solve(S))


t = int(input())
for testIndex in range(t):
	n = int(input())
	a = [0] * n
	a = list(map(int, input().split()))
	a.sort()
	minDif = 1001
	for i in range(1, n):
		minDif = min(a[i] - a[i - 1], minDif)
	print(minDif)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = arr[1] - arr[0]
	for i in range(2, len(arr)):
		ans = min(ans, arr[i] - arr[i - 1])
		if not ans:
			break
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort()
	ans = 1000000000000
	for i in range(n - 1):
		if abs(arr[i] - arr[i + 1]) < ans:
			ans = abs(arr[i] - arr[i + 1])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mn = 10000000
	for i in range(0, len(l) - 1):
		mn = min(mn, abs(l[i] - l[i + 1]))
	print(mn)


def absdif(p, q):
	if p > q:
		return p - q
	elif q > p:
		return q - p
	else:
		return 0

def small(a, n):
	min = absdif(a[0], a[1])
	for i in range(n):
		for j in range(i + 1, n):
			b = absdif(a[i], a[j])
			if min > b:
				min = b
			else:
				continue
		i = i + 1
	return min
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(small(a, n))


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	maxa = 100000000000
	for j in range(1, n):
		maxa = min(maxa, abs(l[j] - l[j - 1]))
	print(maxa)


for _ in range(int(input())):
	n = int(input())
	A = map(int, input().split())
	A = sorted(A)
	M = float('inf')
	for i in range(n - 1):
		cur = A[i + 1] - A[i]
		if M > cur:
			M = cur
	print(M)


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import bisect as bi
import heapq

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def main():
	try:
		n = I()
		l = list(In())
		l.sort()
		mi = 10000000.0
		ele = -1
		pos = -1
		for i in range(1, n):
			temp = l[i] - l[i - 1]
			if abs(temp) < mi:
				mi = abs(temp)
				ele = l[i]
				pos = i
		print(mi)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


def main():
	n_num = int(input())
	for k in range(n_num):
		input()
		a = sorted(list(map(int, input().split(' '))))
		mn = abs(a[0] - a[1])
		for i in range(2, len(a)):
			if mn > abs(a[i] - a[i - 1]):
				mn = abs(a[i] - a[i - 1])
			if mn == 0:
				break
		print(mn)
main()


try:
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		arr.sort()
		mins = arr[1] - arr[0]
		for i in range(1, len(arr) - 1):
			mins = min(mins, arr[i + 1] - arr[i])
		print(mins)
except EOFError:
	pass


t = int(input())
for j in range(t):
	n = int(input())
	array = sorted(list(map(int, input().split())))
	mini = 99999999
	for i in range(1, n):
		c = array[i] - array[i - 1]
		if c < mini:
			mini = c
	print(mini)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mx = float('inf')
	for i in range(n - 1):
		if l[i + 1] - l[i] < mx:
			mx = l[i + 1] - l[i]
	print(mx)


T = int(input())
for z in range(T):
	N = int(input())
	arr = sorted(list(map(int, input().split())))
	ans = 1002
	for i in range(N - 1):
		ans = min(ans, arr[i + 1] - arr[i])
		if ans == 0:
			break
	print(ans)


for i in range(int(input())):
	size = int(input())
	s = list(map(int, input().split()))
	s.sort()
	last = s[0]
	ans = 1000000.0
	for a in s[1:]:
		ans = min(ans, a - last)
		last = a
	print(ans)


t = int(input())
for x in range(t):
	n = int(input())
	athletes = list(map(int, input().split()))
	athletes.sort(reverse=True)
	smallest = None
	for y in range(len(athletes) - 1):
		if smallest is None:
			smallest = athletes[y] - athletes[y + 1]
		elif athletes[y] - athletes[y + 1] < smallest:
			smallest = athletes[y] - athletes[y + 1]
	print(smallest)


N = int(input())
ans = []
for _ in range(N):
	a = 10000
	m = int(input())
	A = list(map(int, input().split()))
	A.sort()
	for i in range(m - 1):
		a = min(A[i + 1] - A[i], a)
	ans.append(a)
for i in ans:
	print(i)


import sys
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right
from collections import deque
from collections import Counter
from itertools import accumulate, combinations, permutations
from heapq import heapify, heappop, heappush
from functools import lru_cache

def input():
	return sys.stdin.readline()[:-1]

def printl(li):
	_ = print(*li, sep='\n') if li else None

def argsort(s, return_sorted=False):
	inds = sorted(range(len(s)), key=lambda k: s[k])
	if return_sorted:
		return (inds, [s[i] for i in inds])
	return inds

def alp2num(c, cap=False):
	return ord(c) - 97 if not cap else ord(c) - 65

def num2alp(i, cap=False):
	return chr(i + 97) if not cap else chr(i + 65)

def matmat(A, B):
	(K, N, M) = (len(B), len(A), len(B[0]))
	return [[sum([A[i][k] * B[k][j] for k in range(K)]) for j in range(M)] for i in range(N)]

def matvec(M, v):
	(N, size) = (len(v), len(M))
	return [sum([M[i][j] * v[j] for j in range(N)]) for i in range(size)]

def T(M):
	(n, m) = (len(M), len(M[0]))
	return [[M[j][i] for j in range(n)] for i in range(m)]

def main():
	mod = 1000000007
	q = int(input())
	for _ in range(q):
		N = int(input())
		A = tuple(map(int, input().split()))
		md = 10000
		for i in range(N):
			for j in range(i + 1, N):
				md = min(md, abs(A[i] - A[j]))
		print(md)
main()


test_case = int(input())
for i in range(test_case):
	length = int(input())
	values = list(map(int, input().split(' ')))
	values.sort()
	min = abs(values[0] - values[1])
	k = 0
	while k < length - 1:
		if abs(values[k] - values[k + 1]) < min:
			min = abs(values[k] - values[k + 1])
		k += 1
	print(min)


t = int(input())
for q in range(t):
	n = int(input())
	entrada = list(map(int, input().split(' ')))
	entrada.sort()
	menor = max(entrada)
	for k in range(n - 1):
		if entrada[k + 1] - entrada[k] < menor:
			menor = entrada[k + 1] - entrada[k]
	print(menor)


T = int(input())
for t_itr in range(T):
	N = int(input())
	A = list(map(int, input().rstrip().split()))
	A.sort()
	m = A[1] - A[0]
	for i in range(1, N - 1):
		m = min(m, A[i + 1] - A[i])
	print(m)


from collections import *
from bisect import *
from math import *
from heapq import *
import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	r = float('inf')
	x = -float('inf')
	x = a[0]
	for i in range(1, n):
		r = min(r, abs(a[i] - x))
		x = max(x, a[i])
	print(r)


t = int(input())
for _ in range(t):
	n = int(input())
	sl = list(map(int, input().split()))
	sl.sort()
	if n == 2:
		print(abs(sl[1] - sl[0]))
		continue
	md = 10000000000000000
	for i in range(n - 1, 0, -1):
		di = sl[i] - sl[i - 1]
		if di < md:
			md = di
	print(md)


def solve():
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	a.sort()
	md = 10000
	for i in range(n - 1):
		md = min(a[i + 1] - a[i], md)
	return md
for t in range(int(input())):
	print(solve())


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	k = abs(lis[1] - lis[0])
	for i in range(n):
		for j in range(i + 1, n):
			k = min(k, abs(lis[i] - lis[j]))
	print(k)


t = int(input())
for tt in range(t):
	n = int(input())
	a = input().split()
	a.sort()
	res = abs(int(a[n - 1]) - int(a[0]))
	for i in range(n):
		for j in range(i + 1, n):
			res = min(res, abs(int(a[j]) - int(a[i])))
	print(res)


import math, sys, bisect
from collections import defaultdict, Counter, deque

def input():
	return sys.stdin.readline().strip()
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])
for _ in range(int(input())):
	N = int(input())
	A = alele()
	A.sort()
	B = []
	for i in range(1, N):
		B.append(A[i] - A[i - 1])
	print(min(B))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	val = 0
	mn = l[-1] - l[-2]
	for i in range(1, len(l)):
		num = abs(l[i] - l[i - 1])
		if num < mn:
			mn = num
	print(mn)


for i in range(int(input())):
	n = int(input())
	arr = [int(arr) for arr in input().split()]
	arr.sort()
	m = arr[1] - arr[0]
	for i in range(2, n):
		t = arr[i] - arr[i - 1]
		if t == 0:
			m = t
			break
		elif t < m:
			m = t
	print(m)


t = int(input())
for i in range(t):
	n = int(input())
	df = list(map(int, input().split()))
	mini = 3000
	df.sort()
	for i in range(0, len(df) - 1):
		mini = min(mini, df[i + 1] - df[i])
	print(mini)


for _ in range(int(input())):
	n = int(input())
	ls = [int(x) for x in input().split()]
	ls.sort()
	ls = ls[::-1]
	mn = int(1000000000.0)
	for i in range(n - 1):
		mn = min(mn, ls[i] - ls[i + 1])
	print(mn)


class Team(object):

	def is_true(self):
		self.n = int(input())
		for i in range(self.n):
			self.difference = 1000000
			self.m = int(input())
			self.c = list(map(int, input().strip().split()))
			self.c.sort()
			self.prev = self.c[0]
			if len(self.c) == 2:
				print(self.c[1] - self.c[0])
			else:
				for j in range(len(self.c) - 1):
					self.diff = self.c[j + 1] - self.c[j]
					if self.difference > self.diff and self.c[j + 1] >= self.prev:
						self.difference = self.diff
						self.prev = self.c[j + 1]
				print(self.difference)
cc = Team()
cc.is_true()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if n == 2:
		print(a[1] - a[0])
		continue
	elif n == 1:
		print(a[0])
		continue
	min = max(a) * 2
	for i in range(len(a) - 1):
		if abs(a[i + 1] - a[i]) < min:
			min = a[i + 1] - a[i]
	print(min)


import math
t = int(input())
for tt in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mm = 1000000000000000
	for i in range(len(arr) - 1):
		mm = min(mm, arr[i + 1] - arr[i])
	print(mm)


t = int(input())
for i in range(0, t):
	n = input()
	s = list(map(int, input().split()))
	s.sort()
	result = 1000
	for j in range(0, len(s) - 1):
		result = min(s[j + 1] - s[j], result)
	print(result)


from functools import reduce
import collections
import itertools
import math
import sys

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(delimiter=' '):
		return input().split(delimiter)

	@staticmethod
	def list_int(delimiter=' '):
		return list(map(int, input().split(delimiter)))

def main():
	t = Read.int()
	for _ in range(t):
		n = Read.int()
		s = sorted(Read.list_int())
		min = s[1] - s[0]
		for i in range(2, n):
			if s[i] - s[i - 1] < min:
				min = s[i] - s[i - 1]
			if min == 0:
				break
		print(min)
main()


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = LIST()
	A.sort()
	ans = INF
	for i in range(N - 1):
		ans = min(ans, A[i + 1] - A[i])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	L = list(map(int, input().split()))
	q = len(set(L))
	if q != n:
		print(0)
	else:
		L.sort()
		p = L[1] - L[0]
		for i in range(n - 1):
			if L[i + 1] - L[i] < p:
				p = L[i + 1] - L[i]
		print(p)


t = int(input())
for i in range(t):
	(n, l) = (int(input()), [int(x) for x in input().split()])
	l.sort()
	m = 999
	for j in range(n - 1):
		if l[j + 1] - l[j] < m:
			m = l[j + 1] - l[j]
	print(m)


import sys
test_cases = int(input())
for i in range(test_cases):
	n = int(input())
	numbers = list(map(int, input().split(' ')))
	numbers.sort()
	diff = sys.maxsize
	for x in range(n - 1):
		if diff > numbers[x + 1] - numbers[x]:
			diff = numbers[x + 1] - numbers[x]
	print(diff)


from sys import stdin, stdout

def input():
	return stdin.readline().strip()

def solve():
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	m = float('inf')
	for i in range(1, n):
		m = min(m, abs(s[i - 1] - s[i]))
	print(m)
for t in range(int(input())):
	solve()


ip = int(input())
s = ''
for i in range(ip):
	j = []
	mkm = int(input())
	k = sorted([int(i) for i in input().split()])
	for i in range(mkm):
		if i != mkm - 1:
			j.append(k[i + 1] - k[i])
	s += str(min(j)) + '\n'
print(s, end='')


t = int(input())
for i in range(0, t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	min_diff = arr[1] - arr[0]
	for j in range(0, n - 1):
		diff = arr[j + 1] - arr[j]
		if diff < min_diff:
			min_diff = diff
	print(min_diff)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mi = 10 ** 19
	for j in range(n - 1):
		a = abs(l[j] - l[j + 1])
		mi = min(a, mi)
		if mi == 0:
			break
	print(mi)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for _ in range(num):
	n = int(z())
	lst = szzz()
	m = float('inf')
	for i in range(1, n):
		if lst[i] - lst[i - 1] < m:
			f = i
			m = lst[i] - lst[i - 1]
	i = f
	print(lst[i] - lst[i - 1])


inp = int(input())
for x in range(0, inp):
	inp1 = input()
	inp2 = input().split()
	u = []
	smallest = 1000
	for num in inp2:
		num = int(num)
		u.append(num)
	inp2 = sorted(u)
	for num in range(0, len(inp2)):
		if num + 1 < len(inp2):
			if abs(inp2[num] - inp2[num + 1]) < smallest:
				smallest = abs(inp2[num] - inp2[num + 1])
	print(smallest)


import sys
input = sys.stdin.readline
for t in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	k = 100000
	for i in range(1, n):
		d = s[i] - s[i - 1]
		if d < k:
			k = d
	print(k)


for t_ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	m = a[1] - a[0]
	for i in range(2, n):
		ans = a[i] - a[i - 1]
		if ans < m:
			m = ans
	print(m)


case = int(input())
for i in range(case):
	element = int(input())
	strength = [int(x) for x in input().split(' ')]
	strength.sort()
	list1 = strength[1:]
	list2 = strength[:-1]
	diff = []
	for i in range(element - 1):
		diff.append(list1[i] - list2[i])
	print(min(diff))


n = int(input())
for i in range(n):
	n1 = int(input())
	s = [int(n) for n in input().split()]
	s.sort()
	l = []
	for i in range(n1 - 1):
		l.append(abs(s[i] - s[i + 1]))
	print(min(l))


import sys
input = sys.stdin.readline
output = sys.stdout

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def solve(arr, n):
	diff = 10 ** 20
	for i in range(n - 1):
		for j in range(i + 1, n):
			if abs(arr[i] - arr[j]) < diff:
				diff = abs(arr[i] - arr[j])
	output.write(str(diff) + '\n')
n = inp()
for i in range(n):
	n1 = inp()
	my_list = inlt()
	solve(my_list, n1)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	min = a[n - 1]
	for j in range(n - 1):
		if a[j + 1] - a[j] < min:
			min = a[j + 1] - a[j]
	print(min)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort(reverse=True)
	m = -1
	p = s[0]
	for e in s[1:]:
		if m == -1 or p - e < m:
			m = p - e
		p = e
	print(m)


for _ in range(int(input())):
	n = int(input())
	l = [*map(int, input().split())]
	l.sort()
	ans = 10 ** 9
	for i in range(n - 1):
		ans = min(ans, l[i + 1] - l[i])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	space = l[1] - l[0]
	for i in range(len(l) - 1):
		space = l[i + 1] - l[i] if l[i + 1] - l[i] < space else space
	print(space)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	mn = 1000000000.0
	for i in range(n - 1):
		ch = abs(s[i + 1] - s[i])
		mn = min(mn, ch)
	print(mn)


import sys

def main():
	res = ''
	input = sys.stdin.readline
	print = sys.stdout.write
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		a.sort()
		d = a[1] - a[0]
		for i in range(n - 1):
			if a[i + 1] - a[i] < d:
				d = a[i + 1] - a[i]
		res += str(d) + '\n'
	print(res)
main()


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]
t = int(input())
for q in range(t):
	n = inputnum()
	s = inputlist()
	s.sort()
	ans = 1000
	for i in range(1, n):
		ans = min(s[i] - s[i - 1], ans)
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().split()
	for j in range(n):
		s[j] = int(s[j])
	s.sort()
	diff = abs(s[0] - s[1])
	for k in range(1, n - 1):
		if abs(s[k] - s[k + 1]) < diff:
			diff = abs(s[k] - s[k + 1])
	print(diff)


t = int(input())
while t:
	t -= 1
	input()
	athelete_code = [int(i) for i in input().split(' ')]
	athelete_code = sorted(athelete_code)
	min_dif = athelete_code[1] - athelete_code[0]
	for i in range(1, len(athelete_code) - 1):
		if athelete_code[i + 1] - athelete_code[i] < min_dif:
			min_dif = athelete_code[i + 1] - athelete_code[i]
	print(min_dif)


def honestcoach(n, s):
	s.sort()
	return min((s[i + 1] - s[i] for i in range(n - 1)))
n = int(input())
for i in range(n):
	a = int(input())
	b = list(map(int, input().split()))
	print(honestcoach(a, b))


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	l = [int(i) for i in input().split()]
	l = sorted(l)
	c = 9999999999999999
	for i in range(1, n):
		c = min(c, abs(l[i] - l[i - 1]))
	print(c)


from sys import maxsize
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = maxsize
	for i in range(n - 1):
		ans = min(ans, abs(arr[i] - arr[i + 1]))
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	min1 = l[1] - l[0]
	for i in range(2, len(l)):
		min1 = min(min1, l[i] - l[i - 1])
	print(min1)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	diff = [l[i + 1] - l[i] for i in range(n - 1)]
	print(min(diff))


for s in [*open(0)][2::2]:
	a = sorted(map(int, s.split()))
	print(min((y - x for (x, y) in zip(a, a[1:]))))


for _ in range(int(input())):
	n = int(input())
	lst = [int(i) for i in input().split()]
	lst.sort()
	res = list()
	for i in range(len(lst)):
		if i + 1 < len(lst):
			res.append(abs(lst[i + 1] - lst[i]))
	print(sorted(res)[0])


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')

def main():
	for _ in range(N()):
		n = N()
		arr = RLL()
		arr.sort()
		res = INF
		for i in range(n - 1):
			res = min(res, arr[i + 1] - arr[i])
		print(res)
main()


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	minimum = 99999999999
	for i in range(1, len(s)):
		if s[i] - s[i - 1] < minimum:
			minimum = s[i] - s[i - 1]
	print(minimum)


t = int(input())
for i in range(t):
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	min_dif = 1000
	for j in range(1, n):
		dif = s[j] - s[j - 1]
		if dif < min_dif:
			min_dif = dif
	print(min_dif)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	m = float('inf')
	for i in range(1, n):
		if abs(arr[i] - arr[i - 1]) < m:
			m = abs(arr[i] - arr[i - 1])
			if m == 0:
				break
	print(m)


for _ in range(int(input())):
	s = int(input())
	r = sorted(list(map(int, input().split())))
	mini = 100000000000
	for i in range(s - 1):
		mini = min(mini, abs(r[i] - r[i + 1]))
	print(mini)


import sys
(input, print) = (sys.stdin.readline, sys.stdout.write)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	min_diff = float('inf')
	for i in range(1, n):
		min_diff = min(min_diff, abs(a[i] - a[i - 1]))
	print(str(min_diff) + '\n')


t = int(input())
while t:
	t -= 1
	n = int(input())
	b = list(map(int, input().split()))
	b.sort()
	mi = []
	for i in range(n):
		for j in range(n):
			if i == j:
				pass
			else:
				mi.append(abs(b[i] - b[j]))
	print(min(mi))


from collections import Counter
import sys
sys.setrecursionlimit(10 ** 6)
mod = 1000000007
inf = int(1e+18)
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]

def inverse(a):
	return pow(a, mod - 2, mod)

def usearch(x, a):
	lft = 0
	rgt = len(a) + 1
	while rgt - lft > 1:
		mid = (rgt + lft) // 2
		if a[mid] <= x:
			lft = mid
		else:
			rgt = mid
	return lft

def solve():
	n = int(input())
	a = sorted(map(int, input().split()))
	ans = inf
	for i in range(n - 1):
		ans = min(ans, abs(a[i] - a[i + 1]))
	print(ans)

def main():
	n = int(input())
	for i in range(n):
		solve()
main()


t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	ans = max(A) - min(A)
	j = 1
	while j != n:
		if A[j] - A[j - 1] == 0 and j == 0 or ans == 0:
			break
		elif A[j] - A[j - 1] < ans:
			ans = A[j] - A[j - 1]
		j += 1
	print(ans)


I = input
for _ in range(int(I())):
	n = int(I())
	a = list(map(int, I().split(' ')))
	a.sort(reverse=True)
	t = 0
	for i in range(n - 1):
		if a[i] == a[i + 1]:
			print('0')
			t = 1
			break
	if t == 0:
		l = []
		for i in range(n - 1):
			l.append(a[i] - a[i + 1])
		print(min(l))


import queue
T = int(input())
d = queue.Queue()
k = 0
for i in range(T):
	N = int(input())
	S = list(map(int, input().split()))
	S.sort()
	d.put(999)
	for j in range(N - 1):
		k = d.get()
		if S[j + 1] - S[j] < k:
			d.put(S[j + 1] - S[j])
		else:
			d.put(k)
	print(d.get())


for i in range(int(input())):
	diff = 2000
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	for i in range(0, n - 1):
		diff = min(abs(s[i] - s[i + 1]), diff)
	print(diff)


for _ in range(int(input())):
	num = int(input())
	numbers = list(map(int, input().split()))
	numbers.sort()
	min_value = None
	for i in range(len(numbers) - 1):
		if min_value is None:
			min_value = abs(numbers[i] - numbers[i + 1])
		elif abs(numbers[i] - numbers[i + 1]) < min_value:
			min_value = abs(numbers[i] - numbers[i + 1])
	print(min_value)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	t = max(l) - min(l)
	for i in range(n - 1):
		if abs(l[i] - l[i + 1]) < t:
			t = abs(l[i] - l[i + 1])
	print(t)


for j in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	min = 10000
	for i in range(0, n - 1):
		for j in range(i + 1, n):
			aux = a[i] - a[j]
			if aux < 0:
				aux = -aux
			if aux < min:
				min = aux
	print(min)


t = int(input())
while t > 0:
	n = int(input())
	li = [int(i) for i in input().split()]
	ans = 1000000000
	for i in range(0, n):
		for j in range(i + 1, n):
			a = max(li[i], li[j])
			b = min(li[i], li[j])
			if a - b < ans:
				ans = a - b
	print(ans)
	t -= 1


T = int(input())
for t in range(T):
	N = int(input())
	strengths = list(map(int, input().split()))
	s = sorted(strengths)
	res = 100000000
	for i in range(N - 1):
		diff = s[i + 1] - s[i]
		res = min(res, diff)
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	a = list()
	for j in range(len(ar)):
		for k in range(len(ar)):
			if k > j:
				a.append(abs(ar[j] - ar[k]))
	ans = min(a)
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = [int(c) for c in str(input()).split()]
	s.sort()
	lmin = s[1] - s[0]
	for k in range(0, n - 1):
		lmin = min(lmin, s[k + 1] - s[k])
	print(lmin)


t = int(input())
for i in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort()
	min = lis[1] - lis[0]
	for i in range(1, len(lis) - 1):
		currDiff = lis[i + 1] - lis[i]
		if currDiff < min:
			min = currDiff
	print(min)


test = int(input())
while test != 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	m = abs(a[0] - a[1])
	for i in range(n - 1):
		for j in range(i + 1, n):
			m = min(m, abs(a[i] - a[j]))
	print(m)
	test -= 1


def strLine():
	return input().split()

def lotInt():
	return map(int, input().split())

def readInt():
	return int(input())

def readStr():
	return input()

def readArr():
	arr = input()
	return [int(n) for n in arr.split()]

def __main():
	t = readInt()
	while t:
		t -= 1
		n = readInt()
		a = readArr()
		a.sort()
		mi = int(1145142333)
		sz = len(a)
		for i in range(sz - 1):
			mi = min(mi, a[i + 1] - a[i])
		print(mi)
__main()


t = int(input())
for i in range(t):
	m = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	i = 0
	min = arr[-1]
	for j in range(1, len(arr)):
		if arr[j] - arr[i] < min:
			min = arr[j] - arr[i]
		i += 1
	print(min)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	min = 10000
	for i in range(len(l) - 1):
		if abs(l[i] - l[i + 1]) < min:
			min = abs(l[i] - l[i + 1])
	print(min)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 999999999999
	for i in range(n - 1):
		ans = min(ans, arr[i + 1] - arr[i])
		if ans == 0:
			break
	print(ans)


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	min_diff = INF
	for i in range(1, n):
		if arr[i] - arr[i - 1] < min_diff:
			min_diff = arr[i] - arr[i - 1]
	print(min_diff)
t = int(input())
for _ in range(t):
	main()


t = int(input())
i = 0
while i < t:
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	diff = 1 << 32
	m = min(l)
	for x in range(1, n):
		if l[x] - l[x - 1] < diff:
			diff = l[x] - l[x - 1]
	print(diff)
	i = i + 1


for _ in range(int(input())):
	input()
	a = sorted(map(int, input().split()))
	x = a[len(a) - 1] - a[len(a) - 2]
	for i in range(len(a) - 1):
		y = a[i + 1] - a[i]
		if x > y:
			x = y
	print(x)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	(x, y) = (0, 0)
	s.sort()
	print(min((abs(s[i] - s[i + 1]) for i in range(n - 1))))


from sys import stdin
for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, stdin.readline().split())))
	m = float('inf')
	for i in range(n - 1):
		m = min(m, abs(arr[i] - arr[i + 1]))
	print(m)


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split(' ')))
	a.sort()
	res = float('inf')
	for i in range(1, len(a)):
		res = min(res, a[i] - a[i - 1])
	print(res)


import sys
sys.setrecursionlimit(10 ** 7)
stdin = sys.stdin
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
ns = lambda : stdin.readline().rstrip()
t = ni()
for i in range(t):
	ans = 10 ** 13
	n = ni()
	s = na()
	s.sort()
	for i in range(len(s) - 1):
		ans = min(ans, s[i + 1] - s[i])
	print(ans)


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	a = input()
	A = list(map(int, list(a.split())))
	A.sort()
	mini = 10 ** 6
	for i in range(n - 1):
		mini = min(A[i + 1] - A[i], mini)
	print(mini)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	minn = 100000000
	for i in range(n - 1):
		v = a[i + 1] - a[i]
		minn = min(minn, v)
	print(minn)


for _ in range(int(input())):
	n = int(input())
	s = sorted([int(i) for i in input().split()])
	mn = s[1] - s[0]
	for i in range(1, n - 1):
		if s[i + 1] - s[i] < mn:
			mn = s[i + 1] - s[i]
	print(mn)


for _ in range(int(input())):
	n = int(input())
	v = list(map(int, input().split()))
	v.sort()
	diff = 2000
	for i in range(1, len(v)):
		diff = min(diff, v[i] - v[i - 1])
	print(diff)


def main():
	a = int(input())
	b = list(map(int, input().split()))
	b.sort()
	mini = 10 ** 9
	for i in range(len(b) - 1):
		mini = min(mini, abs(b[i] - b[i + 1]))
	print(mini)
a = int(input())
for i in range(a):
	main()


z = int(input())
for y in range(z):
	x = int(input())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	m = arr[0] - arr[1]
	for i in range(x - 1):
		if arr[i] - arr[i + 1] < m:
			m = arr[i] - arr[i + 1]
	print(m)


(z, zz, dgraphs) = (input, lambda : list(map(int, z().split())), {})
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for _ in range(num):
	n = int(z())
	l = sorted(zz())
	x = l[0]
	p = 83489734759437597349574375893957934759834798347587349857349875
	for i in l[1:]:
		t = i - x
		if t < p:
			p = t
		x = i
	print(p)


for _ in range(int(input())):
	v = int(input())
	a = list(map(int, input().split()))
	a.sort()
	n = 10000000000000
	for i in range(len(a) - 1):
		if a[i + 1] - a[i] < n:
			n = a[i + 1] - a[i]
	print(n)


import sys
t = int(input())
for i in range(t):
	n = int(input())
	mini = sys.maxsize
	arr = list(map(int, input().split()))
	if n != len(set(arr)):
		print(0)
	else:
		arr.sort()
		for i in range(n - 1):
			res = abs(arr[i] - arr[i + 1])
			if res < mini:
				mini = res
		print(mini)


t = int(input())
for x in range(t):
	n = int(input())
	m = 1000
	l = list(map(int, input().split()))
	l.sort()
	for i in range(1, n):
		if l[i] - l[i - 1] < m:
			m = l[i] - l[i - 1]
	print(m)


from sys import stdin
t = int(input())
for _ in range(t):
	n = int(stdin.readline())
	s = list(map(int, stdin.readline().split()))
	m = -1
	s = sorted(s)
	for i in range(n - 1):
		temp = abs(s[i] - s[i + 1])
		if m == -1:
			m = temp
			continue
		if temp < m:
			m = temp
	print(m)


def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	mini = abs(arr[1] - arr[0])
	for i in range(1, n):
		mini = min(mini, abs(arr[i] - arr[i - 1]))
	return mini
t = int(input())
while t:
	print(solve())
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = 9999
	for i in range(len(l)):
		for j in range(len(l)):
			if ans > abs(l[i] - l[j]) and i != j:
				ans = abs(l[i] - l[j])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	d = []
	for i in range(n - 1):
		d.append(abs(s[i + 1] - s[i]))
	d.sort()
	print(d[0])


def findMinDiff(arr, n):
	diff = 10 ** 20
	for i in range(n - 1):
		for j in range(i + 1, n):
			if abs(arr[i] - arr[j]) < diff:
				diff = abs(arr[i] - arr[j])
	print(diff)
	return
t = int(input())
t1 = []
for i in range(t):
	n = int(input())
	T = input()
	t1 = list(map(int, T.split()))
	findMinDiff(t1, n)


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	a = []
	b = []
	s1 = []
	s1.append(abs(s[0] - s[1]))
	for i in range(1, n - 1):
		s1.append(abs(s[i] - s[i + 1]))
	print(min(s1))


t = int(input())
for _ in range(t):
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort()
	tmp = ls[-1]
	for i in range(1, n):
		if tmp > ls[i] - ls[i - 1]:
			tmp = ls[i] - ls[i - 1]
		if tmp == 0:
			break
	print(tmp)


t = int(input())
for i in range(t):
	n = int(input())
	mi = 10000
	l = [int(x) for x in input().split()]
	l.sort()
	for i in range(1, n):
		if l[i] - l[i - 1] < mi:
			mi = l[i] - l[i - 1]
			if mi == 0:
				break
	print(mi)


t = int(input())
for i in range(0, t):
	n = int(input())
	L = list(map(int, input().split()))
	L.sort()
	m = 10000
	for i in range(0, n - 1):
		m = min(m, L[i + 1] - L[i])
	print(m)


t = int(input())
while t:
	t -= 1
	n = int(input())
	ar = [int(i) for i in input().strip().split()]
	ar.sort()
	l = []
	for i in range(n - 1):
		l.append(abs(ar[i] - ar[i + 1]))
	print(min(l))


import os
os_input = os.read(0, int(10000000.0)).split()
os_input_pos = -1

def cin():
	global os_input_pos
	os_input_pos += 1
	return os_input[os_input_pos]
T = int(cin())
res = []
while T:
	T -= 1
	n = int(cin())
	a = sorted([int(cin()) for i in range(n)])
	ans = 1061109567
	for (i, v) in enumerate(a):
		if i > 0:
			ans = min(ans, v - a[i - 1])
	res.append(str(ans).encode())
os.write(1, '\n'.encode().join(res))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split(' ', n - 1)]
	if n == 2:
		print(abs(a[0] - a[1]))
		continue
	a.sort()
	min = a[n - 1] - a[n - 2]
	for i in range(n - 1, 0, -1):
		if a[i] - a[i - 1] < min:
			min = a[i] - a[i - 1]
	print(min)


import sys
input = sys.stdin.buffer.readline
a = int(input())
for _ in range(a):
	mi = 9999999999999999
	b = int(input())
	c = list(map(int, input().split()))
	c.sort()
	for y in range(b - 1):
		if abs(c[y] - c[y + 1]) < mi:
			mi = abs(c[y] - c[y + 1])
	print(mi)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	k = 1001
	for j in range(len(a)):
		for m in range(len(a)):
			if j != m:
				if abs(a[j] - a[m]) < k:
					k = abs(a[j] - a[m])
	print(k)


t = int(input())
for i in range(t):
	n = int(input())
	si = list(map(int, input().split()))
	si.sort()
	res = si[-1]
	for i in range(1, n):
		res = min(res, si[i] - si[i - 1])
	print(res)


text = [*open(0)]
for s in text[2::2]:
	a = list(map(int, s.strip().split()))
	a.sort()
	ans = min([abs(a[i] - a[i + 1]) for i in range(len(a) - 1)])
	print(ans)


i = int(input())
for _ in range(i):
	n = int(input())
	lz = list(map(int, input().split()))
	lz.sort()
	test = -1
	for j in range(n - 1):
		diff = lz[j + 1] - lz[j]
		if test == -1 or test > diff:
			test = diff
	print(test)


import sys
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	(i, ans) = (0, sys.maxsize)
	while i < n - 1:
		ans = min(ans, arr[i + 1] - arr[i])
		i += 1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	v = []
	dif = 0
	for j in range(1, n):
		dif = abs(s[j] - s[j - 1])
		v.append(dif)
	v.sort()
	print(v[0])


from sys import stdin, stdout
n = int(stdin.readline())
for i in range(n):
	t = int(stdin.readline())
	arr = [int(x) for x in stdin.readline().split()]
	arr.sort()
	diff = 1001
	for x in range(1, t):
		sub = arr[x] - arr[x - 1]
		diff = min(sub, diff)
	stdout.write(str(diff) + '\n')


for _ in range(int(input())):
	a = int(input())
	nums = sorted([int(n) for n in input().split()])
	print(min((b - a for (a, b) in zip(nums[:-1], nums[1:]))))


def solve():
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	min_gap = 2000
	for i in range(1, n):
		min_gap = min(min_gap, abs(a[i] - a[i - 1]))
	return min_gap
t = int(input())
ans = []
for _ in range(t):
	ans.append(solve())
for x in ans:
	print(x)


test_case = int(input())
a = []
my_list = []
for i in range(test_case):
	a.append(int(input()))
	my_list.append([int(j) for j in input().split()])
for x in range(test_case):
	total = max(my_list[x]) - min(my_list[x])
	for y in range(a[x]):
		for z in range(a[x]):
			if abs(my_list[x][y] - my_list[x][z]) < total and y != z:
				total = abs(my_list[x][y] - my_list[x][z])
	print(total)


import math
n = int(input())
for i in range(n):
	k = int(input())
	arr1 = [int(d) for d in list(input().split())]
	arr1.sort()
	arr2 = [int(math.fabs(arr1[i] - arr1[i - 1])) for i in range(1, len(arr1))]
	print(min(arr2))


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		n = I()
		arr = L()
		arr.sort()
		m = 1000000007
		for i in range(1, n):
			m = min(m, abs(arr[i] - arr[i - 1]))
		print(m)
main()


mod = int(1000000000.0) + 7

def ip():
	return int(input())

def Ip():
	return map(int, input().split())
for _ in range(0, int(input())):
	n = ip()
	s = list(Ip())
	s.sort()
	ans = int(1000000000.0)
	for i in range(1, n):
		ans = min(ans, s[i] - s[i - 1])
	print(ans)


a = []
for i in range(int(input())):
	c = 1000
	n = int(input())
	a.append([int(n) for n in input().split()])
	a[i] = sorted(a[i])
	for k in range(len(a[i]) - 1):
		if a[i][k + 1] - a[i][k] < c:
			c = a[i][k + 1] - a[i][k]
	print(c)


t = int(input())
for i in range(t):
	size = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	temp = float('inf')
	n = len(arr)
	for i in range(n - 1, 0, -1):
		if abs(arr[i] - arr[i - 1]) < temp:
			temp = arr[i] - arr[i - 1]
			if temp == 0:
				break
	print(temp)


t = int(input())
for i in range(t):
	n = int(input())
	lis = list(map(int, input().strip().split()))
	lis.sort()
	k = []
	for i in range(1, n):
		k.append(lis[i] - lis[i - 1])
	m = min(k)
	print(m)


t = int(input())
for j in range(t):
	n = int(input())
	aa = [int(a) for a in input().split()]
	aa.sort()
	f = 2 ** 64
	for i in range(n - 1):
		f = min(f, aa[i + 1] - aa[i])
	print(f)


from collections import Counter
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	ans = max(a)
	a.sort()
	for i in range(1, n):
		if ans > a[i] - a[i - 1]:
			ans = a[i] - a[i - 1]
	print(ans)


def func():
	n = int(input())
	a = sorted(list(map(int, input().split())))
	m = a[1] - a[0]
	for i in range(1, n - 1):
		k = a[i + 1] - a[i]
		if m > k:
			m = k
	return m
for _ in range(int(input())):
	print(func())


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().strip().split()))
	l.sort()
	dif = 999
	for i in range(1, n):
		dif = min(dif, l[i] - l[i - 1])
	print(dif)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	min = 999999999
	for i in range(1, n):
		if min > l[i - 1] - l[i]:
			min = l[i - 1] - l[i]
	print(min)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	x = 10000
	for i in range(1, n):
		x = min(x, l[i] - l[i - 1])
	print(x)


t = int(input())
for _ in range(t):
	n = int(input())
	(*arr,) = map(int, input().split())
	arr.sort()
	minval = 10 ** 9 + 7
	for i in range(n - 1, 0, -1):
		minval = min(minval, abs(arr[i] - arr[i - 1]))
	print(minval)


t = int(input())
for i in range(t):
	n = int(input())
	s = sorted(map(int, input().split()), reverse=True)
	print(min([s[j] - s[j + 1] for j in range(len(s) - 1)]))


t = int(input())
for each_t in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	m = 100000000000000000
	i = 0
	while i < n - 1:
		temp = abs(a[i] - a[i + 1])
		if temp < m:
			m = temp
		i += 1
	print(m)


T = int(input())
for t in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	res = 100000
	arr.sort()
	for i in range(n - 1):
		if abs(arr[i] - arr[i + 1]) < res:
			res = abs(arr[i] - arr[i + 1])
	print(res)


n = int(input())
A = []
for x in range(n):
	a = int(input())
	strengthlist = list(map(int, input().split(' ')))
	strengthlist.sort()
	diff = strengthlist[1] - strengthlist[0]
	for y in range(len(strengthlist) - 1):
		if strengthlist[y + 1] - strengthlist[y] < diff:
			diff = strengthlist[y + 1] - strengthlist[y]
	A.append(diff)
for z in range(n):
	print(A[z])


for _ in range(int(input())):
	diff = 1000000
	n = int(input())
	ath = list(map(int, input().split()))
	ath.sort()
	for i in range(n - 1, 0, -1):
		if ath[i] - ath[i - 1] < diff:
			diff = ath[i] - ath[i - 1]
		else:
			continue
	print(diff)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	m = 1000
	for i in range(n - 1):
		m = min(m, a[i + 1] - a[i])
	print(m)


t = int(input())
while t:
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	mini = float('inf')
	for i in range(1, n):
		mini = min(mini, abs(lst[i] - lst[i - 1]))
	print(mini)
	t -= 1


for i in range(int(input())):
	n = int(input())
	l1 = []
	l2 = list(map(int, input().split()))
	for j in range(n):
		for k in range(n):
			if j == k:
				pass
			else:
				l1.append(abs(l2[j] - l2[k]))
	print(min(l1))


def arrange(size, arr):
	arr = sorted(arr)
	min_diff = arr[1] - arr[0]
	for i in range(1, size - 1):
		if min_diff == 0:
			return 0
		loc_min = arr[i + 1] - arr[i]
		if loc_min < min_diff:
			min_diff = loc_min
	return min_diff
n = int(input())
for _ in range(n):
	size = int(input())
	arr = input().split(' ')
	arr = list(map(int, arr))
	print(arrange(size, arr))


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	d = 100000
	for j in range(1, len(s)):
		if abs(s[j] - s[j - 1]) < d:
			d = abs(s[j] - s[j - 1])
	print(d)


for i in range(int(input())):
	n = int(input())
	A = sorted(list(map(int, input().split())))
	nya = A[1] - A[0]
	for i in range(1, n):
		nya = min(nya, A[i] - A[i - 1])
	print(nya)


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mi = 10 ** 20
	for i in range(1, n):
		mi = min(mi, abs(arr[i] - arr[i - 1]))
	print(mi)


import sys

def Ints():
	return map(int, sys.stdin.readline().strip().split())

def Strs():
	return map(str, sys.stdin.readline().strip().split())

def Array():
	return list(map(int, sys.stdin.readline().strip().split()))

def Str():
	return sys.stdin.readline().strip()

def Int():
	return int(sys.stdin.readline().strip())

def MOD():
	return 1000000007

def power(base, power):
	MOD = 1000000007
	result = 1
	while power > 0:
		if power % 2 == 1:
			result = result * base % MOD
		power = power // 2
		base = base * base % MOD
	return result
T = Int()
while T:
	n = Int()
	S = Array()
	S = sorted(S)
	maxs = float('inf')
	for i in range(1, n):
		if abs(S[i - 1] - S[i]) < maxs:
			maxs = min(maxs, abs(S[i - 1] - S[i]))
	print(maxs)
	T -= 1


for _ in range(int(input())):
	n = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	i = 0
	for aa in range(1, len(a)):
		if aa == 1:
			i = a[aa] - a[aa - 1]
		elif aa < len(a):
			if a[aa] - a[aa - 1] < i:
				i = a[aa] - a[aa - 1]
	print(i)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	roznice = []
	for i in range(len(s) - 1):
		roznice.append(abs(s[i] - s[i + 1]))
	x = min(roznice)
	indeks = 0
	for j in range(len(roznice) - 1):
		if roznice[j] == x:
			break
		else:
			indeks += 1
	teamA = s[:indeks + 1]
	teamB = s[indeks + 1:]
	print(abs(max(teamA) - min(teamB)))


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	a.sort()
	ans = abs(a[0] - a[1])
	for i in range(1, n - 1):
		ans = min(ans, abs(a[i] - a[i + 1]))
	print(ans)


from itertools import combinations
for _ in range(int(input())):
	n = int(input())
	ai = list(map(int, input().split()))
	comb = list(combinations(ai, 2))
	print(min([abs(i[0] - i[1]) for i in comb]))


t = int(input())
for i in range(t):
	n = int(input())
	fab = [int(i) for i in input().split()]
	fab.sort()
	ans = 1000
	for i in range(0, n - 1):
		x = fab[i + 1] - fab[i]
		if x < ans:
			ans = x
	print(ans)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = [int(j) for j in input().split()]
	l.sort()
	d = 60000
	for i in range(0, n - 1):
		d = min(d, l[i + 1] - l[i])
	print(d)


t = int(input())
count = 0
while count < t:
	count += 1
	n = int(input())
	l = list(map(int, input().split(' ')))
	l = sorted(l)
	ans = max(l)
	tcount = 0
	while tcount < n - 1:
		comp = l[tcount + 1] - l[tcount]
		if comp < ans:
			ans = comp
		tcount += 1
	print(ans)


from sys import stdin, stdout
input = lambda : stdin.readline().strip()
fast_print = stdout.write
from math import sqrt, floor
T = int(input())
for _ in range(T):
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort()
	print(min((ls[i] - ls[i - 1] for i in range(1, len(ls)))))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	length = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	res = float('inf')
	for i in range(1, len(arr)):
		res = min(res, arr[i] - arr[i - 1])
	print(res)


t = int(input())
for test in range(t):
	n = int(input())
	a = input()
	a = a.strip()
	a = a.split(' ')
	a = list(map(int, a))
	a.sort()
	m = a[-1]
	for i in range(n - 1):
		x = a[i + 1] - a[i]
		if x < m:
			m = x
		if x == 0:
			break
	print(m)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def solve(t):
	min_diff = 1000000000.0
	t.sort()
	for i in range(0, len(t) - 1):
		if abs(t[i] - t[i + 1]) < min_diff:
			min_diff = abs(t[i] - t[i + 1])
		if min_diff == 0:
			break
	print(min_diff)
T = inp()
tests = []
for _ in range(T):
	inp()
	tests.append(inlt())
for t in tests:
	solve(t)


t = int(input())

def fun(n, a):
	ans = 100000
	a.sort()
	for i in range(n - 1):
		ans = min(abs(a[i] - a[i + 1]), ans)
	print(ans)
while t:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	fun(n, a)


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	p.sort()
	ini = 0
	diff = []
	for j in p:
		diff.append(abs(j - ini))
		ini = j
	diff.pop(0)
	print(min(diff))


I = input
t = int(I())
for tt in range(t):
	n = int(I())
	lis = I().split()
	s = []
	for i in lis:
		s.append(int(i))
	m = 1000
	s.sort()
	for i in range(len(s) - 1):
		t = abs(s[i] - s[i + 1])
		if t < m:
			m = t
	print(m)


t = int(input())
while t > 0:
	n = int(input())
	sp = [int(i) for i in input().split()]
	sp.sort()
	m = sp[-1]
	for i in range(n - 1):
		if sp[i + 1] - sp[i] < m:
			m = sp[i + 1] - sp[i]
	print(m)
	t -= 1


number_of_test_cases = int(input())
for i in range(number_of_test_cases):
	number_of_athletes = int(input())
	athletes_strengths = list(map(int, input().split()))
	athletes_strengths.sort()
	result = min([abs(s1 - s2) for (s1, s2) in zip(athletes_strengths[1:], athletes_strengths[:-1])])
	print(result)


def find_min_diff(A):
	A.sort()
	diff = A[1] - A[0]
	if diff:
		for i in range(1, len(A)):
			if A[i] - A[i - 1] < diff:
				diff = A[i] - A[i - 1]
				if diff == 0:
					return 0
		return diff
	else:
		return 0
from sys import stdin as f
t = int(f.readline().strip())
for _ in range(t):
	n = int(f.readline().strip())
	A = [int(i) for i in f.readline().strip().split()]
	print(find_min_diff(A))


t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	mindiff = 1000
	for i in range(1, n):
		if s[i] - s[i - 1] < mindiff:
			mindiff = s[i] - s[i - 1]
	print(mindiff)


t = int(input())
for _ in range(t):
	n = int(input())
	inp = list(map(int, input().split()))
	inp.sort()
	m = 10000
	l = len(inp)
	for e in range(l - 1):
		if inp[e + 1] - inp[e] < m:
			m = inp[e + 1] - inp[e]
	print(m)


n = int(input())
for i in range(n):
	useless_number_for_python = input()
	pows = sorted([int(s) for s in input().split()])
	ans = float('inf')
	for i in range(len(pows) - 1):
		if abs(pows[i] - pows[i + 1]) < ans:
			ans = abs(pows[i] - pows[i + 1])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ma = 100000000
	for j in range(n - 1):
		for k in range(j + 1, n):
			if abs(a[j] - a[k]) < ma:
				ma = abs(a[j] - a[k])
	print(ma)


T = int(input())
for _ in range(T):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = 114514191981036436433 - 4
	for i in range(n - 1):
		a = s[i + 1] - s[i]
		ans = min(ans, a)
	print(ans)


t = int(input())
for z in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	l = []
	for i in range(n - 1):
		x = a[i + 1] - a[i]
		l.append(x)
	print(min(l))


from sys import stdin, stdout
tests = int(stdin.readline())
for j in range(tests):
	num = int(stdin.readline())
	athletes = [int(x) for x in stdin.readline().split()]
	athletes.sort()
	diff = athletes[1] - athletes[0]
	for j in range(1, len(athletes) - 1):
		if athletes[j + 1] - athletes[j] < diff:
			diff = athletes[j + 1] - athletes[j]
	stdout.write(str(diff) + '\n')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	m = max(a) + 1
	for i in range(1, n):
		m = min(a[i - 1] - a[i], m)
	print(m)


from sys import stdin, stdout
for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, stdin.readline().split())))
	s = 10000
	for i in range(n - 1):
		s = min(s, a[i + 1] - a[i])
	print(s)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	sub = []
	for i in range(n - 1):
		sub.append(abs(a[i] - a[i + 1]))
	print(min(sub))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mn = 10000
	for i in range(len(l) - 1):
		if l[i + 1] - l[i] < mn:
			mn = l[i + 1] - l[i]
	print(mn)


for i in range(int(input())):
	n = int(input())
	a = sorted([int(x) for x in input().split()])
	minD = a[1] - a[0]
	for j in range(2, n):
		minD = min(minD, a[j] - a[j - 1])
	print(minD)


from sys import stdin, stdout
lis = lambda : list(map(int, input().split()))
ma = lambda : map(int, input().split())
inte = lambda : int(input())
st = lambda : input()
for i in range(inte()):
	n = inte()
	a = sorted(lis())
	mi = a[1] - a[0]
	for i in range(n - 1):
		mi = min(mi, a[i + 1] - a[i])
	print(mi)


t = int(input())
for i in range(t):
	s = int(input())
	lst = list(map(int, input().split()))
	lst = sorted(lst)
	mn = 1000000
	for i in range(s - 1):
		if lst[i + 1] - lst[i] < mn:
			mn = lst[i + 1] - lst[i]
	print(mn)


t = int(input())
for i in range(t):
	n = int(input())
	x = input().split()
	x = [int(i) for i in x]
	x = sorted(x)
	m = 99999
	for j in range(1, n):
		if m > x[j] - x[j - 1]:
			m = x[j] - x[j - 1]
	print(m)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s = sorted(s)
	de = abs(s[-1] - s[-2])
	for i in range(1, len(s)):
		if de > abs(s[-i] - s[-i - 1]):
			de = abs(s[-i] - s[-i - 1])
	print(de)


import math

def solution():
	n = int(input())
	k = list(map(int, input().split()))
	k = sorted(k)
	mini = 10000000000
	for i in range(1, n):
		mini = min(k[i] - k[i - 1], mini)
	print(mini)
for _ in range(int(input())):
	solution()


import sys
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mini = sys.maxsize
	for i in range(1, n):
		mini = min(mini, abs(arr[i] - arr[i - 1]))
	print(mini)


def solution():
	case_count = int(input())
	for _ in range(case_count):
		_ = input()
		nums = [int(x) for x in input().split()]
		nums.sort()
		min_diff = 1000
		for i in range(1, len(nums)):
			diff = nums[i] - nums[i - 1]
			min_diff = diff if diff < min_diff else min_diff
		print(min_diff)
solution()


def minimum_difference(arr):
	minimum = max(arr)
	for i in range(len(arr)):
		for j in range(len(arr)):
			if i != j and abs(arr[j] - arr[i]) < minimum:
				minimum = abs(arr[j] - arr[i])
	return minimum
loop = int(input())
result_array = []
for p in range(loop):
	miniloop = int(input())
	strength_array = list(map(int, input().split()))
	a = minimum_difference(strength_array)
	result_array.append(a)
for o in result_array:
	print(o)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	e = []
	for i in range(n):
		for j in range(n):
			if i != j:
				e.append(abs(l[i] - l[j]))
	print(min(e))


import math
from collections import defaultdict
import itertools
import random

def solve(s, n):
	s.sort()
	mini = s[1] - s[0]
	for x in range(2, n):
		if s[x] - s[x - 1] < mini:
			mini = s[x] - s[x - 1]
	print(mini)
t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(x) for x in input().split()]
	solve(s, n)


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())), reverse=True)
	diff = l[0] - l[1]
	for i in range(1, n - 1):
		if l[i] - l[i + 1] < diff:
			diff = l[i] - l[i + 1]
	print(diff)


import sys
for i in range(int(sys.stdin.readline().strip())):
	n = int(sys.stdin.readline().strip())
	l = sorted(list(map(int, sys.stdin.readline().strip().split(' '))))
	m1 = 10000
	for i in range(1, len(l)):
		if abs(l[i] - l[i - 1]) < m1:
			m1 = abs(l[i] - l[i - 1])
	print(m1)


n = int(input())
for i in range(n):
	t = int(input())
	member = sorted(list(map(int, input().split(' '))))
	mini = 10 ** 10
	for j in range(t - 1):
		if member[j + 1] - member[j] < mini:
			mini = member[j + 1] - member[j]
		if mini == 0:
			break
	print(mini)


ans = ''
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	m = 36000
	s
	for i in range(0, len(s), 1):
		if i + 1 < len(s):
			m = min(m, s[i + 1] - s[i])
	ans += str(m) + '\n'
print(ans)


from sys import stdin, stdout
T = int(stdin.readline())
for i in range(T):
	n = int(stdin.readline())
	s = list(map(int, stdin.readline().split()))
	s.sort()
	min_dif = s[1] - s[0]
	i = 2
	while i < len(s):
		min_dif = min(min_dif, s[i] - s[i - 1])
		if min_dif == 0:
			break
		i += 1
	out = min_dif
	stdout.write(str(out) + '\n')


t = int(input())
for tc in range(t):
	n = int(input())
	num = list(map(int, input().split()))
	num.sort()
	mi = 100000000000
	va = num[1] - num[0]
	if va < mi:
		mi = va
	for i in range(1, n - 1):
		ca = num[i + 1] - num[i]
		if ca < mi:
			mi = ca
	print(mi)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	ans = 9999
	zero = False
	for j in range(len(s) - 1):
		if abs(s[j] - s[j + 1]) == 0:
			print(0)
			zero = True
			break
		elif abs(s[j] - s[j + 1]) < ans:
			ans = abs(s[j] - s[j + 1])
	if not zero:
		print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(j) for j in input().split()[:n]]
	a.sort(reverse=False)
	x = a[n - 1]
	for i in range(n - 1):
		if a[i + 1] - a[i] < x:
			x = a[i + 1] - a[i]
			p = i
	print(a[p + 1] - a[p])


t = int(input())
for i in range(t):
	c = int(input())
	min = 9999999999999
	cc = [int(s) for s in input().split()]
	cc.sort()
	for k in range(1, len(cc)):
		if cc[k] - cc[k - 1] < min:
			min = cc[k] - cc[k - 1]
	print(min)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = a.copy()
	b.sort()
	m = 10 ** 4
	for i in range(1, len(b)):
		d = b[i] - b[i - 1]
		if d < m:
			m = d
			i1 = b[i - 1]
			i2 = b[i]
	print(i2 - i1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))[:n]
	a.sort()
	ans = 2147483648
	for j in range(n - 1):
		if a[j + 1] - a[j] < ans:
			ans = a[j + 1] - a[j]
	print(ans)


from sys import *
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	s = list(map(int, stdin.readline().split()))
	s.sort()
	j = 0
	min = 10 ** 9
	for i in range(1, n):
		if abs(s[j] - s[i]) < min:
			min = abs(s[j] - s[i])
		j = j + 1
	print(min)


import math
for _ in range(int(input())):
	n = int(input())
	ll = list(map(int, input().split()))
	if n == 2:
		print(abs(ll[1] - ll[0]))
		continue
	ll.sort()
	z = []
	for i in range(1, len(ll)):
		z.append(ll[i] - ll[i - 1])
	print(min(z))


def solve(x, lst):
	ans = 100000
	ar = sorted(lst, key=None, reverse=False)
	for i in range(x - 1):
		for j in range(i + 1, x):
			ans = min(ans, abs(ar[i] - ar[j]))
	print(ans)
t = int(input())
for i in range(t):
	x = int(input())
	lst = list(map(int, input().split()))
	solve(x, lst)


t = int(input())
for ts in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	mind = a[-1] - a[0]
	for i in range(n - 1):
		mind = min(mind, a[i + 1] - a[i])
	print(mind)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	diff = max(l)
	flag = 0
	for i in range(1, len(l)):
		if l[i] - l[i - 1] < diff:
			diff = l[i] - l[i - 1]
			if diff == 0:
				flag = 1
				print(0)
				break
	if flag == 0:
		print(diff)


import sys
import math
import random
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	n = inp()
	ara = inara()
	ara.sort()
	ans = ara[n - 1] - ara[0]
	for i in range(n - 1):
		ans = min(ans, ara[i + 1] - ara[i])
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	v = 10 ** 9
	for i in range(n - 1):
		v = min(v, abs(a[i] - a[i + 1]))
	print(v)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = float('inf')
	for i in range(n - 1):
		d = min(d, l[i + 1] - l[i])
	print(d)


def sol(a):
	s = max(a)
	for j in range(len(a) - 1):
		for i in range(len(a) - 1):
			if a[i + 1] < a[i]:
				a_1 = a[i + 1]
				a[i + 1] = a[i]
				a[i] = a_1
	for i in range(len(a) - 1):
		if a[i + 1] - a[i] < s:
			s = a[i + 1] - a[i]
	return s
t = int(input())
for i in range(t):
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	print(sol(a2))


def solve(n, t):
	l = sorted(t)
	s = set(l)
	if len(s) == len(l):
		z = [l[i + 1] - l[i] for i in range(n - 1)]
		return min(z)
	elif len(l) == 2:
		return l[1] - l[0]
	else:
		return 0
for _ in range(int(input())):
	(n, t) = (int(input()), list(map(int, input().split())))
	print(solve(n, t))


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	currentMin = 99999999
	for i in range(0, len(a) - 1):
		for j in range(i + 1, len(a)):
			number = abs(a[i] - a[j])
			if number < currentMin:
				currentMin = number
	print(currentMin)


t = int(input())
for i in range(t):
	n = int(input())
	x = []
	z = 0
	y = 1
	s = [int(i) for i in input().split()]
	while z != n - 1:
		for j in range(y, n):
			x.append(((s[z] - s[j]) ** 2) ** 0.5)
		z += 1
		y += 1
	print(int(min(x)))


from sys import stdin, setrecursionlimit, stdout
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline().rstrip()
res = ['YES', 'NO']
test_case = ii()
while test_case:
	test_case -= 1
	n = ii()
	a = li()
	a.sort()
	ans = 100000
	for i in range(1, n):
		ans = min(ans, a[i] - a[i - 1])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	mn = 1001
	for i in range(n - 1):
		if s[i + 1] - s[i] < mn:
			mn = s[i + 1] - s[i]
	print(mn)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mini = arr[1] - arr[0]
	for i in range(0, n):
		for j in range(i + 1, n):
			mini = abs(min(abs(arr[i] - arr[j]), mini))
	print(abs(mini))


for i in range(int(input())):
	vals = []
	n = int(input())
	prompt = [int(i) for i in input().split(' ')]
	for i in range(len(prompt)):
		for l in range(len(prompt)):
			if i == l:
				continue
			vals.append(abs(prompt[i] - prompt[l]))
	print(min(vals))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	min = abs(l[0] - l[1])
	for i in range(n):
		for j in range(n):
			if i != j and abs(l[i] - l[j]) < min:
				min = abs(l[i] - l[j])
	print(min)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	diff = 10000000
	for j in range(n - 1):
		temp = abs(l[j] - l[j + 1])
		if temp < diff:
			diff = temp
	print(diff)


z = lambda : int(input())
z1 = lambda : input()
z2 = lambda : map(int, input().split())
for _ in ' ' * z():
	a = z()
	b = sorted(z2())
	print(min((b[i] - b[i - 1] for i in range(1, a))))


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [Scanner.string() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [Scanner.int() for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def solve():
	N = Scanner.int()
	A = Scanner.map_int()
	A.sort()
	ans = INF
	for i in range(N - 1):
		ans = min(ans, A[i + 1] - A[i])
	print(ans)

def main():
	T = Scanner.int()
	for _ in range(T):
		solve()
main()


t = int(input())
while t != 0:
	t = t - 1
	n = int(input())
	arr = list(map(int, input().strip().split()))[:n]
	arr.sort()
	ans = 2147483647
	for i in range(0, n - 1):
		ans = min(ans, arr[i + 1] - arr[i])
	print(ans)


count = int(input())
for i in range(count):
	size = int(input())
	players = [int(x) for x in input().split()]
	players.sort()
	differences = [players[idx + 1] - players[idx] for idx in range(len(players) - 1)]
	print(min(differences))


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t * 2):
	if i % 2 == 0:
		p = input()
	else:
		x = input().split()
		x = [int(a) for a in x]
		x.sort()
		min_diff = 10 ** 18
		for j in range(len(x) - 1):
			min_diff = min(min_diff, abs(x[j] - x[j + 1]))
		print(min_diff)


inp_test = int(input())
for i in range(0, inp_test):
	len_inp = int(input())
	list_inp = list(map(int, input().split(' ')))
	list_inp = sorted(list_inp)
	listdiff = []
	for i in range(0, len(list_inp) - 1):
		listdiff.append(abs(list_inp[i] - list_inp[i + 1]))
	print(min(listdiff))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	ans = 1000000000.0
	for i in range(n - 1):
		ans = min(arr[i + 1] - arr[i], ans)
	print(ans)


from sys import stdin
input = iter(stdin.readlines()).__next__
t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted(map(int, input().split()))
	diffs = [s[i] - s[i - 1] for i in range(1, n)]
	print(min(diffs))


import sys
lines = []
for line in sys.stdin:
	if 'Exit' == line.rstrip():
		break
	lines.append(line)
t = int(lines[0])
for i in range(1, 2 * t, 2):
	n = int(lines[i])
	athletes = [int(x) for x in lines[i + 1].split(' ')]
	athletes = sorted(athletes)
	min_dif = float('inf')
	for j in range(1, n):
		if athletes[j] - athletes[j - 1] < min_dif:
			min_dif = athletes[j] - athletes[j - 1]
	print(min_dif)


t = int(input())
for i in range(t):
	n = int(input())
	array = [int(s) for s in input().split()]
	array = sorted(array)
	ans = max(array)
	for i in range(1, len(array)):
		if array[i] - array[i - 1] < ans:
			ans = array[i] - array[i - 1]
	print(ans)