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

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)

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

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

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)

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)

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

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)

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)

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)

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)

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)

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)

Python: n=int(input())
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
        
print(answer)

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

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

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

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

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)

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

Python: # coding: utf-8
while 1:
    n=int(input())
    if n==0:
        break
    d=sorted(list(map(int,input().split())))
    mn=99999999
    for i in range(1,len(d)):
        mn=min(mn,d[i]-d[i-1])
    print(mn)

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

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)