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
}

C++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 0x2aaaaaaa; // 715,827,882
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };


#define fs  first
#define sc  second



int a[1000];

int main() {

	for (;;) {
		int n;


		cin >> n;
		if (n == 0) break;

		rep(i, n) cin >> a[i];

		int ret = 0x1fffffff;

		sort(a, a + n);
		rep(i, n - 1) ret = min(ret, a[i + 1] - a[i]);

		cout << ret << endl;
	}

}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
	
	int n;
	int a[1100];
	int point[51000]; //データセットごとの点数
	int count = 1;
	
	while (1)
	{
		cin >> n;
		
		if(n == 0) break;
		
		for (int i = 0; i < n; i++) cin >> a[i];
		
		sort(a, a+n, greater<int>());
		
		int proa;
		int d;
		//データセットごとの作業
		for (int i = 0; i < n; i++) {
			
			// 隣のデータとの差
			d = abs(proa - a[i]);
			
			// 初期値は最大点
			if(i == 0) point[count - 1] = a[0];
			
			if(d < point[count - 1]) point[count - 1] = d;
			
			proa = a[i];
		}
		
		count++;
	}
	
	for (int i = 0; i < count; i++) {
		cout << point[i] << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        int a[n];
        for (auto &ai:a) {
            cin >> ai;
        }
        sort(a, a+n);
        int prev = -1000000, ans = 1000000;
        for (auto &ai:a) {
            ans = min(ans, ai - prev);
            prev = ai;
        }
        cout << ans << '\n';
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

int main(){

  int n, i, j;
  int a[11000];

  while(cin >> n, n){
    for(i = 0; i < n; i++){
      cin >> a[i];
    }
    sort(a, a+n);
    int ans = 1000000;
    for(i = 0; i < n-1; i++){
      for(j = i+1; j < n; j++){
        ans = min(ans, a[j]-a[i]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=;i<n;i++)cin>>a[i];
    sort(a,a+n);
  int p=100000000;
  for(int i=0;i<n-1;i++)p=min(p,a[i+1]-a[i]);
    cout<<p<<endl;
}

C++: #include <bits/stdc++.h>

using namespace std;

int n[1000]={};
long long a[1000][1000]={};
long long ans = 10000000000;

int main(){
    int s=0;
    while(1){
        scanf("%d",&n[s]);
        if(n[s] == 0){
            break;
        }
        for(int i=0;i<n[s];i++){
           scanf("%lld",&a[s][i]); 
        }
        s++;
    }

    int times =s;
    int sub;
    for(int i=0;i<s;i++){
        sort(a[i],a[i]+n[i]);
        for(int j=0;j<n[i]-1;j++){
            sub = abs(a[i][j] - a[i][j+1]);
            if(ans >= sub){
                ans = sub;
            }
        }
        cout << ans << endl;
        ans = 1000000000;
    }
    

    return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int n;
        cin >> n;
        if (n == 0) return;

        vector<int> v(n);
        rep(i, 0, n) cin >> v[i];
        sort(all(v));

        int ans = v[1] - v[0];
        for (int i = 0; i + 1 < n; ++i) {
            chmin(ans, v[i + 1] - v[i]);
        }
        cout << ans << endl;
        solve();
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}