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++: #include <bits/stdc++.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	while(true) {
		int n;
		cin>>n;
		if(n==0) break;
		int a[n];
		REP(i,n) cin>>a[i];
		sort(a,a+n);
		int ans=INF;
		REP(i,n-1) ans=min(ans,a[i+1]-a[i]);
		cout<<ans<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

bool debug=true;
/*---------------------------------------------------*/

int main(){
  int n,x,mini;
  vi v;
  while(cin>>n){
    mini=INF;
    if(n==0)break;
    v.clear();
    rep(i,n){
      cin>>x;
      v.pb(x);
    }
    sort(all(v));
    rep(i,v.size()-1){
      mini=min(mini,v[i+1]-v[i]);
    }
    cout<<mini<<endl;
  }
  return 0;
}

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

int main() {
	int N;
	while (cin >> N) {
		if (N == 0) break;
		vector<int> A(N);
		for (int i = 0; i < N; i++) cin >> A[i];
		sort(A.begin(), A.end());
		int ANS = 100000000;
		for (int i = 0; i < N - 1; i++) {
			ANS = min(ANS, A[i + 1] - A[i]);
		}
		cout << ANS << endl;
	}
}

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

C++: #include<iostream>
#include<algorithm>
#define SEISEKI 10000000

using namespace std;

int main() {
	while (1) {
		int n;
		int ans=SEISEKI;

		cin >> n;
		int a[1001];
		if (n == 0)break;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}

		sort(a, a+n);	//昇順

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

C++: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#define all(c) (c).begin(),(c).end()

using namespace std;

int main(void){

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

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

using namespace std;


int main() {
	int n;
	int o = 0;
	
	while (cin >> n, n != 0) {
		o = 100;
		vector<int> a(10000, 0);
		vector<int> b(10000, 0);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a.rbegin(), a.rend());

		for (int i = 0; i < n - 1; i++) {
			b[i] = a[i] - a[i + 1];
		}
		for (int i = 0; i < n - 1; i++) {
			if (i == 0) {
				o = b[0];
			}
			else {
				if (b[i] < o) {
					o = b[i];
				}
			}
		}
		cout << o << endl;
	}
}

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

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)
			break:
		int a[n];
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		int s=1000001;
		for(int i=0;i<n;i++){
			for(int j=0;j<n-1;j++){
				if(s>abs(a[i]-a[j])){
					s=abs(a[i]-a[j]);
				}
			}
		}
		cout<<s<<endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	while(true){
		int n;
		cin >> n;
		if(n == 0){
			break;
		}
		int a[2000];
		for(int i = 0; i < n; i++){
			cin >> a[i];
		}
		sort(a, a + n);
		int ans = a[n - 1] - a[0];
		for(int i = 0; i < n - 1; i++){
			if(a[i + 1] - a[i] < ans){
				ans = a[i + 1] - a[i];
			}
		}
		cout << ans << endl;
	}
	return 0;
	
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll n;
VL a;

signed main() {
    while(cin >> n) {
        if(n == 0) break;
        REP(i, n) a.emplace_back(IN());
        sort(All(a));
        ll ans = LINF;
        REP(i, n - 1) { ans = min(ans, a[i + 1] - a[i]); }
        cout << ans << "\n";
        a.clear();
    }
}