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 <iostream>

using namespace std;

int myabs(int i){
  if(i > 0){return i;}
  else{return -i;}
}

int main(void){
  while(1){
    int n;
    cin >> n;
    if(n == 0) {return 0;}

    int a[n];

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

    long int diff;
    long int ans = 500000000;

    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
        diff = myabs(a[i] - a[j]);
        if(i != j && ans > diff){
          ans = diff;
        }
      }
    }

    cout << ans << endl;
  }
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	for (int n; cin >> n&&n;) {
		vector<int> a(n); rep(i, 0, n) { cin >> a[i]; }
		sort(a.begin(), a.end());
		int ans = INF;
		rep(i, 1, a.size()) {
			ans = min(ans, a[i] - a[i - 1]);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int *line;
	while(cin>>n&&n!=0){
		line=new int[n];
		for(int i=0;i<n;++i){
			cin>>line[i];
		}
		sort(line,line+n);
		--n;
		int ans=(1<<31)-1;
		for(int i=0;i<n;++i){
			ans=min(ans,line[i+1]-line[i]);
		}
		cout<<ans<<endl;
		delete[] line;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n;
	while(cin>>n and n>0){
		int a[n]; rep(i,n) cin>>a[i];
		sort(a,a+n);

		int ans=1e9;
		rep(i,n-1){
			if(a[i+1]-a[i]<ans) ans=a[i+1]-a[i];
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main (){
    int n;
	while(cin>>n && n){
		vector<int> v(n);
		int ans=100000000;
		for(int i=0;i<n;i++)cin>>v[i];

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i!=j)ans=min(ans,abs(v[i]-v[j]));
			}
		}
		cout<<ans<<endl;
	}
}

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

const int MAX=1e7+10;

int n,ans;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n,n){
        vector<int> a(n);
        for (int i=0;i<n;++i) cin >> a[i];
        ans=MAX;
        for (int i=0;i<n;++i)
            for (int j=i+1;j<n;++j)
                ans=min(ans,abs(a[i]-a[j]));
        cout << ans << endl;
    }
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

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

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  while(true){
    int n;
    cin>>n;
    if(n==0)return 0;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int Min=INT_MAX;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i==j)continue;
        if(Min>abs(a[i]-a[j])){
          Min=abs(a[i]-a[j]);
        }
      }
    }
    cout<<Min<<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 <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

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