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

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)

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

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;

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

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

Python: #成績の差が最も小さい 2 人を選ぶプログラム

#1 行目には学生の人数 n (2 ≤ n ≤ 1000)
#2 行目には　 ai（1 ≤ i ≤ n）が i 番目の学生の成績
while True:
 #1行目nを読み込む
  n =int(input())
  #もしn==0ならbreak
  if n==0:
    break
  else :
     #配列a[i]を読み込む(1<=i<=n)
    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)

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)

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

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)

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)

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

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

Python: # AOJ 1608: Selection of Participants of an Experime...
# Python3 2018.7.13 bal4u

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)

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)

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

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

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

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)

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)

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

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)

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

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

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)

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