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

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

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)

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)

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)

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)

		# ans = abs(A[0] - A[1])
for ans in ans_list:
	print(ans)

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

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

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)

Python: while True:
	n,m = map(int,input().split())
	if n == 0 and m == 0:	
		break
	a = list(map(int,input().split()))
	a.sort()
	list1 = []
	for i in range(n):
		for j in range(i + 1, n):
		 	price1 = a[i] + a[j]
		 	list1.append(price1)
	list1.sort()
	list2 = list(filter(lambda p: m >= p, list1))


	if list2:
		print(max(list2))
	else:
		print("NONE")

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

sys.setrecursionlimit(10**7)
inf = 10**3
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: 
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))

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 == []:
        break
    if n == 0:
        break
    print(min(l))

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)

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 # for not subtract last + 1 from last

    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)
        # print("data_list", data_list) # debug
        # print("sorted_list", sorted_list) # debug
        checker = Checker(sorted_list)
        checker.detect_min_num()
        min_num = checker.min_num
        # print("min_num", min_num) # debug
        print(min_num)