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;

int main(){
    int n;
    while(cin >> n, n){
        vector<int> v(n);
        for(int i = 0; i < n; i++) cin >> v[i];
        sort(v.begin(), v.end());
        int ans = 1e9;
        for(int i = 0; i < n - 1; i++){
            ans = min(ans, abs(v[i] - v[i + 1]));
        }
        cout << ans << endl;
    }

}

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

using namespace std;

int main(){
    int  n;
    while(cin>>n,n){
        vector<int>students(n);
        for(int i=0;i<n;++i){
            cin>>students[i];
        }
        sort(students.begin(),students.end());
        int ans=100000000;
        for(int i=1;i<n;++i){
            ans=min(ans,students[i]-students[i-1]);
        }
        cout<<ans<<endl;
    }
}

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

int main() {
	for( ;; ) {
		int n;
		cin >> n;

		if( n == 0 ) { break; }

		vector<int> a( n );
		for( auto& v: a ) { cin >> v; }

		int result = 1000000;

		for( int i = 0; i < n; ++i ) {
			for( int j = i+1; j < n; ++j ) {
				result = min( result, abs( a.at(i) - a.at(j) ) );
			}
		}

		cout << result << endl;
	}
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

void func(int n){
	int table[n];

	for(int i = 0; i < n; i++)scanf("%d",&table[i]);

	int ans = 2000000;

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

	printf("%d\n",ans);

}


int main(){

	int n;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		func(n);
	}

	return 0;
}

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

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    while(true){
        int ans = mod;
        int N; cin >> N;
        if(N == 0) break;
        vector<int> A(N);
        rep(i, N) cin >> A[i];
        sort(A.begin(), A.end());
        rep(i, N-1) ans = min(ans, A[i+1]-A[i]);
        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
int n = 0;
std::vector<int> a;
int main(void){

    while(std::cin >> n, n != 0){
        a.resize(n);
        for(int i=0; i<n; ++i){
            std::cin >> a[i];
        }

        std::sort(a.begin(), a.end());

        int res = INT_MAX;
        for(int i=0; i<n-1; ++i){
            res = std::min(res, a[i+1]-a[i]);
        }
        std::cout << res << std::endl;
    }
}

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

#define reps(i,j,k) for(int i=j;i<k;i++)
#define rep(i,j) reps(i,0,j)

using namespace std;

typedef vector<int> vi;

int main(){
	
	int n;
	while(cin >> n, n){
		vi v(n);
		cin >> v[i];
		sort(v.begin(), v.end());
		int m = (1<<29);
		rep(i,n-1){
			m = min(m, v[i+1] - v[i]);
		}
		cout << m << endl;
	}

	return 0;
}

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





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

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

int main() {
  int n;
  while (cin >> n, n) {
    auto a = vector<int>(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(begin(a), end(a));

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

C++: #include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,a[1000],ans;
int main(void){
    while(1){
    cin>>n;
    if(n==0)return 0;
    ans=1000000;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n-1;i++){
        ans=min(ans,a[i+1]-a[i]);
    }
    cout<<ans<<endl;
    }
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;while (cin >> n, n) { vector<int> v(n);REP(i, n) cin >> v[i];SORT(v);int ans = 1e9;REP(i, n - 1)ans = min(ans, v[i + 1] - v[i]);cout << ans << endl; }
}

C++: #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		vi a(n);
		for(int i=0;i<n;i++) cin>>a[i];
		sort(a.begin(),a.end());
		int res=inf;
		for(int i=0;i<n-1;i++) res=min(res,a[i+1]-a[i]);
		cout<<res<<endl;
	}
}

C++: #include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (int u = 0; u < 50; u++)
	{
		long n,a[1001];

		cin >> n;
		if (n == 0)
		{
			break;
		}
		
		long p = 10000;
	
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		
		sort(a,a + n);
	
		for (int i = 0; i < n; i++)
		{
			for (int j = 1; j < n; j++)
			{
				if (i < j && a[j] - a[i] < p)
				{
					p = 0;
					p = a[j] - a[i];
				}
			}
		}
	
		cout << p << endl;
	}
}