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

int main(void){
    while(true){
        int n=0, min = 10000000, dif=0, score[1010];
        cin >> n;
        if(n==0) break;
        for(int i=0;i<n;++i) cin >> score[i];
        for(int i=0;i<n;++i){
            for(int j=i+1;j<n;++j){
                int dif = abs(score[i]-score[j]);
                if(min > dif) min = dif;
            }
        }
        cout << min << endl;
    }
}

C++: #include "bits/stdc++.h"

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while (cin >> n&&n != 0) {
		vector<int>  v(n);
		int cmin = INF;
		REP(i, n) {
			cin >> v[i];
		}
		REP(i, n) {
			REP(j, n) {
				if(i!=j)
				cmin = min(cmin, abs(v[i] - v[j]));
			}
		}
		cout << cmin << endl;
	}

	return 0;
}

C++: using namespace std;
typedef long long ll;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
 
int main(){
    int N;
    cin >> N;
    vector<ll> ans;
    while (N!=0)
    {
        vector<ll> a;
        a.resize(N);
        for (int i = 0; i < N; i++) cin >> a[i];
        ll thismin = 1e10;
        for (int i = 0; i < N;i++) {
            for (int n = 0; n < N; n++) {
                if (n == i) continue;
                thismin = min(thismin, abs(a[i] - a[n]));
            }
        }
        ans.push_back(thismin);
        cin >> N;
    }
    for (auto i : ans) {
        cout << i << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    int n;
    int ans=1000;

    while(cin>>n){
        if(n==0)break;
        else{
            ans=1000;
            vector<int> v;

            for(int i=0;i<n;i++){
                int a;
                cin>>a;
                v.push_back(a);
            }

            sort(v.begin(),v.end());
            
            for(int i=0;i<n-1;i++){
                ans=min(ans,v[i+1]-v[i]);
            } 
            cout<<ans<<endl;
        }
    }
}

C++: #include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <cerrno>
#include <cfenv>
#include <math.h>
#include <iomanip>
#include <limits>
#define ll long long int

using namespace std;

int main(){

    int n;

    while(true){

        vector<int> data(1000);

        cin >> n;

        if(n==0){
            break;
        }

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

        sort(data.begin(),data.begin()+n);

        vector<int> dis(1000);

        for(int i=0;i<n-1;i++){
            dis[i] = data[i+1]-data[i];
        }

        sort(dis.begin(),dis.begin()+n-1);

        cout << dis[0] << endl;

    }

    return 0;
}

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

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

using namespace std;

int main(){
  int n;

  while(cin>>n,n){
    int temp1,temp2;
    vector<int> score;
    int mini=1000000;

    for(int i=0;i<n;++i){
      cin>>temp1;
      score.push_back(temp1);
    }

    sort(score.begin(),score.end());
      
    for(int i=0;i<n-1;++i){
      mini=min(mini,score[i+1]-score[i]);
	}

    cout<<mini<<endl;
  }
}

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

int main() {
        int n , i , x , min;
       while(true){ cin >> n;
    if(n!=0){
        min = 10000000;
        vector<int> v(n,0);
        for(i = 0;i<n;i++){
            cin >> v.at(i);
        }
        for(int j = 0;j<n;j++){
            for(i = 0;i<n;i++){
                if(j!=i){
                    if(v.at(j)>=v.at(i)){
                x = v.at(j)-v.at(i);
                if(x<min) min = x;
            }}
           }   
        }
        cout << min << endl;
    }
else{break;}
  
}
}

C++: #include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main(void) {
	int n = 0;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int A[1000];
		for (int i = 0; i < 1000; i++) {
			A[i] = 0;
		}
		for (int i = 0; i < n; i++) {
			cin >> A[i];
		}
		for (int i = 0; i < n - 1; i++){
			for (int j = i + 1; j < n; j++) {
				if (A[i] > A[j]) {
					int tmp = A[i];
					A[i] = A[j];
					A[j] = tmp;
				}
			}
		}
		int min = 1000000;
		for (int i = 0; i < n - 1; i++) {
			if (A[i + 1] - A[i] < min) {
				min = A[i + 1] - A[i];
			}
		}
		cout << min << endl;
	}
	return 0;
}

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

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

	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

set<int>ng={'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};

signed main()
{
	IOS();
	vector<int>ans;
	while(1){
		int N;
		cin>>N;
		if(N==0)break;
		vector<int>a(N);
		for(int i = 0;i < N;i++){
			cin>>a[i];
		}
		sort(all(a));
		int mi = INF;
		rep(i,0,N-1)chmin(mi,a[i+1]-a[i]);
		ans.push_back(mi);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}