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++: /*
    Problem

*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    while(1) {
        int n;
        cin >> n;
        if (n == 0) return 0;
        vector<int> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];
        sort(a.begin(), a.end());
        int minD = INF;
        for (int i = 0; i < n-1; i++) {
            int d = a[i+1] - a[i];
            minD = (d < minD ? d : minD);
        }
        cout << minD << '\n';
    }
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;

int main() {
  int a;
  while (cin >> a, a) {
    int b[a], c[a - 1];
    rep(i, a) cin >> b[i];
    sort(b, b + a);
    rep(i, a - 1) c[i] = b[i + 1] - b[i];
    cout << *min_element(c, c + a - 1) << endl;
  }
  return 0;
}

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

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> p(n);
        for (auto& i : p) cin >> i;
        sort(p.begin(), p.end());

        int ans = 1<<28;
        for (int i = 0; i < n-1; i++) {
            ans = min(ans, p[i+1]-p[i]);
        }

        cout << ans << endl;
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
  int a[n];
  for(int i=0;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 <iostream>
#include <algorithm>
using namespace std;

int main() {
    while (true) {
        int n, arr[1010];
        cin >> n;
        if (n == 0) { break; }
        int ret = 1 << 30;
        for (int j = 0; j < n; ++j) {
            cin >> arr[j];
        }
        sort(arr, arr+n);
        for (int j = 0; j < n-1; ++j) {
            ret = min(ret, arr[j+1]-arr[j]);
        }
        cout << ret << endl;
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> scores(n);
  for (int i = 0; i < n; i++) {
    cin >> scores[i];
  }

  int min_diff = 1000000;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j)  {
        int diff = abs(scores[i] - scores[j]);
        min_diff = min_diff > diff ? diff : min_diff;
      }
    }
  }
  cout << min_diff << endl;
}

C++: #include <iostream>

#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
using ll=long long;
int main(){
    while(1){
   int n;
   cin >> n;
   if(n==0){
       break;
   }
   vector<ll> vec(n);
   for(int i=0;i<n;i++){
       int x;
       cin >> x;
       vec[i]=x;
   }
   
   ll MIN=1e9;
   for(int i=0;i<n;i++){
       for(int j=i+1;j<n;j++){
           MIN = min(abs(vec[i]-vec[j]),MIN);
       }
   }
   cout << MIN <<endl;
    }
}

C++: #include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    for(int n; cin >> n, n;){
        vi a(n); for(auto& e: a) cin >> e;
        sort(_all(a));

        int minDiff = a[1] - a[0];
        rep(i, n - 1){
            int diff = a[i + 1] - a[i];
            chmin(minDiff, diff);
        }

        cout << minDiff << endl;
    }

    return 0;
}

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

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
vector<ll> a;

int main() {
	while (cin >> n&&n) {
		a.resize(n);
		rep(i, n) {
			cin >> a[i];
		}
		sort(ALL(a));
		ll ans = INF;
		rep(i, n - 1) {
			ans = min(ans, a[i + 1] - a[i]);
		}
		cout << ans << endl;
	}
}