t=int(input())
for ii in range(t):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=999999999999
for i in range(n-2):
ans=min(ans,abs(a[i]-a[i+1])+abs(a[i+2]-a[i+1]))
print(ans)
1715A - Crossmarket | 1715C - Monoblock |
1512C - A-B Palindrome | 1679B - Stone Age Problem |
402A - Nuts | 792A - New Bus Route |
221A - Little Elephant and Function | 492C - Vanya and Exams |
1369B - AccurateLee | 892B - Wrath |
999A - Mishka and Contest | 727C - Guess the Array |
1625C - Road Optimization | 1715D - 2+ doors |
267A - Subtractions | 1582A - Luntik and Concerts |
560A - Currency System in Geraldion | 946A - Partition |
1068B - LCM | 1692E - Binary Deque |
679A - Bear and Prime 100 | 488A - Giga Tower |
14A - Letter | 1150A - Stock Arbitraging |
1552A - Subsequence Permutation | 1131F - Asya And Kittens |
1475F - Unusual Matrix | 133B - Unary |
1547A - Shortest Path with Obstacle | 624A - Save Luke |