Problem:
Selection of Participants of an Experiment Dr. Tsukuba has devised a new method of programming training.
In order to evaluate the effectiveness of this method,
he plans to carry out a control experiment.
Having two students as the participants of the experiment,
one of them will be trained under the conventional method
and the other under his new method.
Comparing the final scores of these two,
he will be able to judge the effectiveness of his method. It is important to select two students having the closest possible scores,
for making the comparison fair.
He has a list of the scores of all students
who can participate in the experiment.
You are asked to write a program which selects two of them
having the smallest difference in their scores. Input The input consists of multiple datasets, each in the following format.  n  a 1  a 2 … a n  A dataset consists of two lines.
The number of students n is given in the first line. n is an integer satisfying 2 ≤ n ≤ 1000.
The second line gives scores of n students. a i (1 ≤ i ≤ n ) is the score of the i -th student, which is a non-negative integer not greater than 1,000,000. The end of the input is indicated by a line containing a zero.
The sum of n 's of all the datasets does not exceed 50,000. Output For each dataset, select two students with the smallest difference in their scores,
and output in a line (the absolute value of) the difference. Sample Input 5
10 10 10 10 10
5
1 5 8 9 11
7
11 34 83 47 59 29 70
0 Output for the Sample Input 0
1
5

Solution (Python):



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

Solution (Python):
n=int(input())
result=[]

while n!=0:
    data=list(map(int,input().split()))
    data=sorted(data)
    answer=1000000

    for i in range(0,n-1):
        d=data[i+1]-data[i]
    
        if d<answer:
            answer=d
        
    result.append(answer)
    
    n=int(input())

for i in range(0,len(result)):
    print(result[i])

Solution (Python):
anslist = []

while True:
    n = int(input())
    if not n:
        break

    a = list(map(int, input().split()))

    ans = 10 ** 10
    for i in range(n):
        for j in range(n):
            if i != j:
                ans = min(ans, abs(a[i] - a[j]))

    anslist.append(ans)

for i in anslist:
    print(i)

Solution (Python):
while True:
    N = int(input())
    if N == 0:
        break
    A = sorted(list(map(int, input().split())))
    ans = float('inf')
    for i in range(1, len(A)):
        ans = min(abs(A[i] - A[i - 1]), ans)
    print(ans)

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

while True:
    n = int(input())
    if n == 0:
        break
    else:
        aa = inpl()
        aa.sort()
        ans = INF
        for i in range(1,n):
            ans = min(aa[i] - aa[i-1],ans)
        print(ans)

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    a = sorted(list(map(int, input().split())))
    ans = 1000001
    for i in range(n - 1):
        j = a[i + 1] - a[i]
        if j < ans:
            ans = j
    print(ans)

Solution (Python):
while True:
    n=int(raw_input())
    if n==0: break
    a=sorted(map(int,raw_input().split()))
    d=10**9
    for i in xrange(n-1):
        d=min(d,a[i+1]-a[i])
    print d

Solution (Python):
while True:
    Sa = 1000000
    n = int(input())
    if n == 0:
        break
    Num_lis = list(map(int,input().split()))
    Num_lis = sorted(Num_lis)
    for i in range(n - 1):
        if Num_lis[i + 1] - Num_lis[i] < Sa:
            Sa = Num_lis[i + 1] - Num_lis[i]
    print(Sa)

Solution (Python):
while True:
    n = int(input())
    if n==0: break
    l = list(map(int,input().split()))
    r = []
    for i in range(n):
        for j in range(i+1,n):
            r += [abs(l[i]-l[j])]
    print(min(r))

Solution (Python):
while True:
    n = int(input())
    if n==0: break
    l = sorted(list(map(int,input().split())))
    r = []
    for i in range(n-1):
        r += [l[i+1]-l[i]]
    print(min(r))

Solution (Python):
while 1:
    n = input()
    if n==0:
        break
    A = map(int, raw_input().split())
    ans = 1e18
    for i in xrange(n):
        for j in xrange(n):
            if i==j: continue
            ans = min(ans, abs(A[i]-A[j]))
    print ans

Solution (Python):
while 1:
    n=int(input())
    if n==0:break
    a=sorted(list(map(int,input().split())))
    print(min(a[i+1]-a[i] for i in range(n-1)))

Solution (Python):
while True:
    N = int(input())
    if not N:
        break
    A = sorted(map(int, input().split()))
    print(min(A[i+1] - A[i] for i in range(N-1)))

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    a = sorted(list(map(int, input().split())))
    minv = 1000000
    for i in range(n-1):
        minv = min(minv, a[i+1]-a[i])
    print(minv)

Solution (Python):
while True:
  n = int(input())
  if n==0:
     break
  a = [int(i) for i in input().split()]

  a.sort()
  mindiff = 10000000
  for i in range(n-1):
    mindiff = min(mindiff, a[i+1]-a[i])
  print(mindiff)

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

Solution (Python):
while True:
    if int(input()) == 0:
        break
    s = sorted(map(int, input().split()))
    r = min(abs(x - y) for (x, y) in zip(s, s[1:]))
    print(r)

Solution (Python):
while True:
	n=int(input())
	if n==0:break
	a=list(map(int,input().split()))
	a.sort()
	saisho=1000000
	for i,iv in enumerate(a):
		if i!=0:
			saisho=abs(iv-b) if saisho > abs(iv-b)else saisho
		b=iv
	print(saisho)

Solution (Python):
while True:
	n=int(input())
	if n==0:break
	a=list(map(int,input().split()))
	a.sort()
	saisho=1000000
	for i,iv in enumerate(a):
		if i!=0:
			saisho=abs(iv-b) if saisho > abs(iv-b)else saisho
		b=iv
	print(saisho)

Solution (Python):
while True:
	n=int(input())
	if n==0:break
	a=list(map(int,input().split()))
	a.sort()
	saisho=1000000
	for i,iv in enumerate(a):
		if i!=0:
			saisho=abs(iv-b) if saisho > abs(iv-b)else saisho
		b=iv
	print(saisho)

Solution (Python):
while True:
	n=int(input())
	if n==0:break
	a=list(map(int,input().split()))
	a.sort()
	saisho=1000000
	for i,iv in enumerate(a):
		if i!=0:
			saisho=abs(iv-b) if saisho > abs(iv-b)else saisho
		b=iv
	print(saisho)

Solution (Python):
while 1:
    n = int(input())
    if n == 0:
        break
    a = sorted(map(int,raw_input().split()))
    b = []
    for i in range(n-1):
        b.append(a[i+1]-a[i])
    print min(b)

Solution (Python):

def solve(N):
    A = list(map(int, input().split()))
    ans = 1e9
    for i in range(N):
        for j in range(N):
            if i != j:
                d = abs(A[i] - A[j])
                if ans > d:
                    ans = d
    print(ans)

while True:
    N = int(input())
    if N > 0:
        solve(N)
    else:
        break

Solution (Python):
if __name__ == '__main__':
    while 1:
        n = int(input())
        if n ==0 :break
        line = list(map(int,input().strip().split()))
        diff = max(line)
        for i in range(n-1):
            for j in range(i+1,n):
                if diff > abs(line[i] - line[j]):diff = abs(line[i]-line[j])
        print(diff)

Solution (Python):
if __name__ == '__main__':
    while 1:
        n = int(input())
        if n ==0 :break
        line = list(map(int,input().strip().split()))
        diff = 1000000
        for i in range(n-1):
            for j in range(i+1,n):
                if diff > abs(line[i] - line[j]):diff = abs(line[i]-line[j])
        print(diff)

Solution (Python):
while True:
    N = int(input())
    if N == 0: break
    src = list(map(int,input().split()))
    src.sort()
    ans = 10**7
    for s1,s2 in zip(src,src[1:]):
        ans = min(ans, s2-s1)
    print(ans)

Solution (Python):
while True:
    n = int(raw_input())

    if n == 0:
        break

    a = sorted(map(int, raw_input().split()))

    print min([a[i+1]-a[i] for i in range(n-1)])

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break

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

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    l = list()
    for i in range(0, n):
        for j in range(0, n):
            if i == j:
                continue
            l.append(abs(a[i]-a[j]))
    else:
        print(min(l))

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break

    a = sorted(list(map(int, input().split())))
    
    
    b = []
    for i, x in enumerate(a[:-1]):
        b.append(abs(x - a[i+1]))
    print(min(b))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break
        a = sorted(LI())
        r = inf
        for i in range(n-1):
            tr = a[i+1] - a[i]
            if r > tr:
                r = tr
        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())

Solution (Python):


while True:
    n = int(input())
    if n == 0:
        break
    l = list(map(int, input().split()))
    l.sort()
    l.reverse()
    min = 10**10
    for i in range(n-1):
        dif = l[i] - l[i+1]
        if dif < min:
            min = dif
    print(min)

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    arr = list(map(int, input().split()))
    arr.sort()
    ge = arr[-1]
    for i in range(n - 1):
        tmp = arr[i + 1] - arr[i]
        if tmp < ge:
            ge = tmp
    print(ge)

Solution (Python):
while int(input()):
  l=sorted(map(int,input().split()))

  ll=range(len(l))
  m=[0 for _ in ll]
  m[1]=abs(l[0]-l[1])
  for i in ll[2:]:
    m[i]=min(m[i-1],abs(l[i]-l[i-1]))
  print(m[-1])

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    ans = 100000000
    for i in range(n - 1):
        for j in range(i + 1, n):
            ans = min(ans, abs(a[i] - a[j]))
    print(ans)

Solution (Python):
BIG_NUM=10000000
while True:
    n=int(input())
    if n==0:
        break
    else:
        a=sorted(list(map(int,input().split())))
        tmp=BIG_NUM
        for i in range(n-1):
            tmp=min(tmp,a[i+1]-a[i])
        print(tmp)

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    A = sorted(list(map(int, input().split())))
    D =[]
    for i in range(n - 1):
        D.append(A[i + 1] - A[i])
    print(min(D))

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    scores = [int(line) for line in input().split()]
    scores.sort()
    c = scores[1] - scores[0]
    for i in range(2, n):
        if scores[i] - scores[i - 1] < c:
            c = scores[i] - scores[i - 1]
    print(c)

Solution (Python):

while True:
    n = int(input())
    if n == 0: break
    dataset = list(map(int, input().split()))
    dataset.sort()

    minimumDiff = 99999999999999
    for i in range(0,n-1):
        temp = dataset[i+1] - dataset[i]
        if minimumDiff > temp:
            minimumDiff = temp
    print(minimumDiff)

Solution (Python):
n = int(input())

while n!=0:
    a = list(map(int,input().split()))
    data = []
    for i in range(len(a)-1):
        for j in range(i+1,len(a)):
            data.append(abs(a[i]-a[j]))
    n = int(input())
    print(min(data))

Solution (Python):

while True:
    num = int(input())
    if num == 0:break

    
    line = sorted(list(map(int,input().split())))
    kotae = []
    
    
    for i in range(0,num - 1):
        num1 = abs(line[i] - line[i + 1])
        kotae.append(num1)
    print(min(kotae))

Solution (Python):
while True:
    n=int(input())
    if n==0:break;
    a=list(map(int, input().split()))
    a.sort()
    ans=a[1]-a[0]
    for i in range(2, n):
        if a[i]-a[i-1]<ans:ans=a[i]-a[i-1]
    print(ans)

Solution (Python):
n = int(input())
while n != 0:
    a = list(map(int, input().split()))
    ans = float("inf")
    for i in range(n-1):
        for j in range(i+1, n):
            res = abs(a[i] - a[j])
            if ans > res:
                ans = res
    print(ans)
    n = int(input())

Solution (Python):
while 1:
    n = int(input())
    if n == 0:
        break
    a = list(map(int,input().split()))
    Min = 9999999999
    a.sort()
    for i in range(n-1):
        Min = min(Min,abs(a[i] - a[i+1]))
    print(Min)

Solution (Python):
while True:
    n = int(input())
    if n==0:break
    a = list(map(int, input().split()))

    a = sorted(a)

    ans = 10000000

    for i in range(len(a)-1):
        if a[i+1]-a[i] < ans:
            ans = a[i+1]-a[i]

    print(ans)

Solution (Python):
def get_input():
    input_data = int(input())
    return input_data

def get_data_list():
    data_list = input().split()
    for i in range(len(data_list)):
        data_list[i] = int(data_list[i])
    return data_list

class Checker:
    def __init__(self, sorted_list):
        self.sorted_list = sorted_list
        self.a = 0
        self.b = 1
        self.min_num = float("inf")
        self.try_num = len(self.sorted_list) - 1 

    def detect_min_num(self):
        for i in range(self.try_num):
            tmp_num = self.sorted_list[self.b] - self.sorted_list[self.a]
            if tmp_num <= self.min_num:
                self.min_num = tmp_num
            self.a, self.b = self.b, self.b + 1


if __name__ == "__main__":
    while True:
        student_num = get_input()
        if student_num == 0:
            break
        data_list = get_data_list()
        sorted_list = sorted(data_list)
        
        
        checker = Checker(sorted_list)
        checker.detect_min_num()
        min_num = checker.min_num
        
        print(min_num)

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

while True:
  mans = inf
  n=int(input())
  if n == 0: exit()
  A=list(map(int,input().split()))
  for i in range(n-1):
    for j in range(i+1,n):
      mans = min(mans,abs(A[i]-A[j]))
  print(mans)

Solution (Python):
while True:
    n = int(input())
    if(n == 0): break
    a = list(map(int,input().split()))
    a.sort()
    ans = 10**9
    for i in range(n-1):
        ans = min(ans,a[i+1]-a[i])
    print(ans)

Solution (Python):
while 1:
    n = int(input())
    if n == 0:break
    a = sorted(list(map(int, input().split())))
    b = [a[i+1] - a[i] for i in range(n-1)]
    print(min(b))

Solution (Python):
while True:
    a = int(input())
    if a == 0:
        break
    b = sorted(list(map(int,input().split())))
    di = -1
    for i in range(a-1):
        h = b[i+1]-b[i]
        if di == -1 or h < di:
            di = h
    print(di)

Solution (Python):
l = []
for i in range(50000):
  n = int(input())
  if n == 0:
    break
  else:
    A = list(map(int,input().split()))
    for i in range(n):
      for j in range(i+1,n):
        l.append(abs(A[i]-A[j]))
    print(min(l))
    l.clear()

Solution (Python):
while True :
    n = int(input())
    if(n == 0) :
        break
    else :
        A = list(map(int, input().split()))
        d = 1000000
        
        for i in range(n - 1) :
            for j in range(i + 1, n) :
                s = abs(A[i] - A[j])
                if(s < d) :
                    d = s
                else :
                    pass
        
        print(d)

Solution (Python):






import sys
import math


class mymath:
    
    pi = 3.14159265358979323846264338

    
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    def pnum_check(self, n):
        if (n==1):
            return False
        elif (n==2):
            return True
        else:
            for x in range(2,n):
                if(n % x==0):
                    return False
            return True

    
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

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

    
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans
    
    
    def is_integer(self, n):
        try:
            float(n)
        except ValueError:
            return False
        else:
            return float(n).is_integer()

    
    def dist(self, A, B):
        d = 0
        for i in range(len(A)):
            d += (A[i]-B[i])**2            
        d = d**(1/2)
        return d

    
    def abs(self, n):
        if n >= 0:
            return n
        else:
            return -n

mymath = mymath()


class output:
    
    def list(self, l):
        l = list(l)
        
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()






















def printA(A):
    N = len(A)
    for i, n in enumerate(A):
        print(n, end='')
        if i != N-1:
            print(' ', end='')
    print()










def get_input():
    N = []
    while True:
        try:
            N.append(input())
            
            
        except EOFError:
            break
    return N

while True:
    N = int(input())
    if N==0:
        break
    A = [int(x) for x in input().split()]

    ans = 1145141919

    A.sort()

    for i in range(N-1):
        if ans > abs(A[i]-A[i+1]):
            ans = abs(A[i]-A[i+1])

    print(ans)

Solution (Python):
ans_list = []

while True:
    n = int(input())
    if n == 0:
        break
    A = list(map(int,input().split()))
    ans = float("inf")
    for i in range(n):
        for j in range(i+1,n):
            res = abs(A[i]-A[j])
            ans = min(ans, res)
    ans_list.append(ans)

for ans in ans_list:
    print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

flag = True
ans_list = []
N = 1
while(flag == True):
	N = INT()
	if N == 0:
		flag = False
	else:
		A = LIST()
		A.sort()
		ans = abs(A[0] - A[1])
		for i in range(N - 1):
			ans = min(ans, abs(A[i] - A[i + 1]))
		ans_list.append(ans)

		
for ans in ans_list:
	print(ans)

Solution (Python):
while True:
    n = int(input())
    if n==0:
        break
    a = list(map(int,input().split()))
    a.sort()

    res = a[1]-a[0]
    for i in range(1,n):
        res = min(res,a[i]-a[i-1])
    print(res)

Solution (Python):
while True:
  n=int(input())
  if n==0:
    break
  a=list(map(int,input().split()))
  x=[]
  for i in range(n):
    for j in range(i+1,n):
      b=a[i]-a[j]
      if b<0:
        b=b*(-1)
      x.append(b)
  print(min(x))

Solution (Python):
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2,gcd
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits


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


def INT(): return int(input())


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


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


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    ans=[]

    while 1:
        n = INT()
        if n==0:
            break
        else:
            a=LIST()
            a.sort()
            mi=max(a)
            for i in range(n-1):
                for j in range(i+1,n):
                    mi=min(mi,a[j]-a[i])

            ans.append(mi)

    for x in ans:
        print(x)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
def MAP(): return map(int, input().split())

ans = []
while 1:
	n = INT()
	if n == 0:
		break
	a = LIST()
	a.sort()
	min_ = 100000000
	for i in range(n-1):
		min_ = min(min_, abs(a[i] - a[i+1]))
	ans.append(min_)
for x in ans:
	print(x)

Solution (Python):

while True:
	n = int(input())
	if n == 0: break
	score = list(map(int,input().split()))
	score.sort()
	ans = max(score)
	for i in range(1,n):
		aa = abs(score[i] - score[i-1])
		if ans > aa:
			ans = aa
	print(ans)

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    x = list(map(int,input().split()))
    x = sorted(x)
    ans = 1000000
    for i in range(n-1):
        ans = min(ans,x[i+1]-x[i])
    print(ans)

Solution (Python):
from itertools import combinations

ans_list = []

while True:
    n = int(input())
    if n == 0:
        break
    A = list(map(int,input().split()))
    ans = float("inf")
    for (a, b) in combinations(A,2):
        ans = min(ans,abs(a-b))
    ans_list.append(ans)

for ans in ans_list:
    print(ans)

Solution (Python):
while True:
    n=int(input())
    if n==0:break
    l=list(map(int,input().split()))
    l.sort()
    ans=l[-1]-l[0]
    for i in range(n-1):
        ans=min(ans,l[i+1]-l[i])
    print(ans)

Solution (Python):
def main(n):
    a = list(map(int, input().split()))
    a.sort()
    ans = 10 ** 20
    for i in range(n - 1):
        if ans > a[i + 1] - a[i]:
            ans = a[i + 1] - a[i]
    print(ans)

while 1:
    n = int(input())
    if n == 0:
        break
    main(n)

Solution (Python):
for v in range(1000):
  s = input()
  s = int(s)
  if s == 0:
    break
  else:
    x=[]
    A = input().split()
    B = [int(l) for l in A]
    for i in range(s):
      for j in range(s):
        if i==j:
          pass
        else:
          w=B[i]-B[j]
          w = abs(w)
          x.append(w) 
  print(min(x))

Solution (Python):

while True:
    min = 1000000
    n =(int)(input())
    if n==0:
        break
    a = list(map(int, input().split()))

    for i in range (n-1):
        for j in range (i+1,n):
            num = a[i]-a[j]
            if min>abs(num):
                min = abs(num)
    print(min)

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    a = [int(x) for x in input().split()]
    ans = 10000000
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            if abs(a[i]-a[j])<ans:
                ans = abs(a[i]-a[j])
    print(ans)

Solution (Python):
import itertools

while True:
    n = int(input())
    
    if n == 0:
    	break
    
    score_lst = [int(i) for i in input().split()]
    
    dist = 1000001
    
    for i1, i2 in itertools.combinations(score_lst, 2):
    	if abs(i1 - i2) < dist:
    		dist = abs(i1 - i2)
    		
    print(dist)

Solution (Python):
while True:
    N = int(input())
    if N == 0:
        break
    s = list(map(int, input().split()))
    ans = []
    for i in range(N-1):
        for j in range(N):
            if(i < j):
                if s[i] > s[j] or s[i] < s[j]:
                    tmp = abs(s[i]-s[j])
                    ans.append(tmp)
                if s[i] == s[j] and not i == j:
                    ans.append(0)
    print(min(ans))

Solution (Python):
while(True):
  n = int(input())
  if n == 0:
    break
  else:
    lis = list(map(int,input().split()))
    lis.sort()
    min = 10**9+7
    i = 0
    while(i<len(lis)-1):
      if lis[i+1] - lis[i] < min:
        min = lis[i+1] - lis[i]
      i += 1
    print(min)

Solution (Python):
ans = []

while True:
    n = int(input())
    if n == 0:
        break
    a = sorted(list(map(int, input().split())))
    min_ = a[-1]
    for i in range(1, n):
        min_ = min(min_, a[i] - a[i-1])
    ans.append(min_)

for i in ans:
    print(i)

Solution (Python):
import sys
def main():
    while True:
        n = int(input())
        if not n:
            return
        aa = list(map(int,input().split()))
        ans = sys.maxsize
        for i in range(n):
            for j in range(n):
                if i == j:
                    continue
                ans = min(abs(aa[i]-aa[j]),ans)
        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
while 1:
  n = int(input())
  if n == 0:
    break
  A = list(map(int, input().split()))
  A.sort()
  m = 1000000
  t=0
  for i in range(n):
    for j in range(1+i,n):
      t=abs(A[i]-A[j])
      if t<= m:
        m = t
  print(m)

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int,input().split()))
    a.sort()
    ans = 10**10
    for i in range(n-1):
        ans = min(ans, abs(a[i]-a[i+1]))
    print(ans)

Solution (Python):




while True:
 
  n =int(input())
  
  if n==0:
    break
  else :
     
    a = sorted(list(map(int, input().strip().split())))
    
    a_sub = 1000000
    for i in range(n-1):
      if abs(a[i]-a[i+1]) < a_sub :
        a_sub =  abs(a[i]-a[i+1])
    print(a_sub)

Solution (Python):


import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N = int(input())
    if N == 0:
        exit()
    L = list(map(int, input().split()))
    L = sorted(L)
    min_diff = float('inf')
    for l1, l2 in zip(L, L[1:]):
        min_diff = min(min_diff, abs(l1-l2))
    print(min_diff)


while True:
    solve()

Solution (Python):
while True:
  n = int(input())
  if n==0:
    break
  a = sorted(list(map(int, input().split())))
  ans = 1000000
  for i in range(n-1):
    ans = min(ans, a[i+1]-a[i])
  print(ans)

Solution (Python):
j = 0
while 1:
    m = int(input())
    if m == 0:
        break
    a = list(map(int,input().split()))
    min = 99999999999
    a.sort()
    for i in range(len(a)-1):
        num = a[i+1] - a[i]
        if min > num:
            min = num
    print(min)
    j += 1

Solution (Python):
while True:
    try:
        ans=1000000
        n=int(input())
        ls=list(map(int,input().split()))
        ls.sort()
        for i in range(1,n):
            if ls[i]-ls[i-1]<ans:
                ans=ls[i]-ls[i-1]
        print(ans)
    except:
        break;

Solution (Python):

def solve(n,a):
    
    a.sort()
    ans = abs(a[0]-a[1])
    for i in range(n-1):
        ans = min(ans,abs(a[i] - a[i+1]))
    return ans

while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int,input().split()))
    print(solve(n,a))

Solution (Python):
def main():
    while True:
        s_num = int(input())
        
        if s_num == 0:
            return
        
        s_dat = input()
        s_dat = s_dat.split(" ")
        
        for j in range(len(s_dat)):
            s_dat[j] = int(s_dat[j])
            
        s_dat.sort()

        answer = sa(s_dat)
        print(answer)

def sa(array):
    min_dist = 1000000 + 1
    
    for i in range(len(array) - 1):
        dist = array[i + 1] - array[i]
        
        if dist <= min_dist:
            min_dist = dist

    return min_dist
    
main()

Solution (Python):
n=int(input())
while n!=0:
    a=list(map(int,input().split()))
    ans=10**18
    for i in range(len(a)):
        for j in range(len(a)):
            if i!=j:
                ans=min(ans,abs(a[i]-a[j]))
    print(ans)
    n=int(input())

Solution (Python):
while 1:
    n=int(input())
    if n==0:break
    a=list(map(int,input().split()))
    a.sort()
    ans=float("inf")
    for i in range(n-1):
        ans=min(ans,a[i+1]-a[i])
    print(ans)

Solution (Python):
while 1:
    n = int(input())
    if n == 0:
        break

    data = list(map(int, input().split()))
    data.sort()

    ans = 10**9
    for i in range(1, n):
        if data[i] - data[i-1] < ans:
            ans = data[i] - data[i-1]

    print(ans)

Solution (Python):
while True:
    n = int(input())
    if n == 0: break
    a = list(map(int, input().split()))
    a.sort()
    ans = a[1]-a[0]
    for i in range(2, n):
        if a[i]-a[i-1] < ans: ans = a[i]-a[i-1];
    print(ans)

Solution (Python):
e=1
while e==1:
    n = int ( input() )
    if n==0:
        break
    a = input().split(" ")
    for j in  range(n):
        a[j] = int( a[j])
    a.sort()

    sa=11451419

    for i in range ( n-1 ):
        sa = min (sa ,a[i+1] - a[i])

    print(sa)

Solution (Python):
while True:
    n=int(input())
    if n==0:
        break
    a=sorted(list(map(int, input().split())))
    b=[]
    for i in range(n-1):
        c=a[i+1]-a[i]
        b.append(c)
    d=min(b)
    print(d)

Solution (Python):
min_list = []
while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(int, input().split()))
    s.sort(reverse=True)
    min1 = s[0] - s[1]
    for i in range(n-1):
        min1 = min(min1, s[i]-s[i+1])
    min_list.append(min1)

for i in range(len(min_list)):
    print(min_list[i])

Solution (Python):
while True:
    n=int(input())
    if n==0: break
    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))

Solution (Python):
import sys
f = sys.stdin
while True:
    n = int(f.readline())
    if n == 0:
        break
    myset = set()
    diff = sys.maxsize
    for tmp in f.readline().split():
        tmp = int(tmp)
        for score in myset:
            if abs(tmp - score) < diff:
                diff = abs(tmp - score)
                if diff == 0:
                    break
        myset.add(tmp)
    print(diff)

Solution (Python):
while True:
    
    n = int(input())
    if n==0:
        break
    s = sorted(list(map(int, input().split(" "))))

    d = 11234567
    for i in range(n-1):
        d = min(d, s[i+1]-s[i])
    print(d)

Solution (Python):
def getMinGap(data):
	result = list()
	for n in range(len(data)):
		for m in range(n + 1, len(data)):
			result.append(abs(data[n] - data[m]))
	result = set(result)
	return min(result)

while  True:
	n = int(input())
	if n == 0:
		break
	data = [int(x) for x in input().split()]
	print(getMinGap(data))

Solution (Python):
while 1:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    ans = float("inf")
    for i in range(1,n):
        for j in range(i):
            ans = min(ans, abs(a[i]-a[j]))
    print(ans)