Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	for {
		n := nextInt()
		if n == 0 {
			break
		}
		an := make([]int, n)
		min := 1000000
		for i := 0; i < n; i++ {
			an[i] = nextInt()
		}
		sort.Ints(an)
		for i := 1; i < n; i++ {
			sub := an[i] - an[i-1]
			if min > sub {
				min = sub
			}
		}
		fmt.Println(min)
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

Python: # coding=utf-8

###
### for python program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    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

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

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

    ### Mat Multiplication
    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
    
    ### intチェック
    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()

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

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
# print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
# print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
# print(" {}".format(i), end="")

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

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート（代入する必要なし）
# N.sort()

# 10000個の素数リスト
# P = mymath.pnum_eratosthenes(105000)

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(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)

Python: while True:
    n = int(input())#人数の受け取り
    if n == 0:#０人or何も入力しないなら終了
        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]))#絶対値を受け取り用のlistに入力
    else:#listが完成したら
        print(min(l))#成績の一番近い生徒の差を出力

Python: f=lambda s,t:abs(s-t)

while 1:
    n=int(input())
    if not n:break
    a=sorted(list(map(int,input().split())))
    s,t=a[:2]
    for i in a[2:]:
        u=f(s,t)
        if u>abs(s-i):
            t=i
        elif u>abs(t-i):
            s=i
    print(f(s,t))

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))

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)

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))

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)

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])

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)

Python: while True:
    n = int(input())
    a = list(map(int, input().split()))
    l = list()

    for i in range(1, n-1):
        for j in range(i+1,n):
            l.append(abs(a[i]-a[j]))
    if l == []:
        continue
    if n == 0:
        break
    print(min(l))

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)

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())

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