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

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)

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)

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)

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

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

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)

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

Python: #!/usr/bin/env python3
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)

Python: # -*- coding: utf-8 -*-
# python template for atcoder1
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()

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

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)

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)

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)

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)

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)

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)

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)

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

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)

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)

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)

Python: #入力数を入力し、0だったら入力を終わる
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))

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)