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;

constexpr int INF = (1 << 29);

int main()
{
    int N;
    while (cin >> N, N) {
        vector<int> a(N);
        for (int i = 0; i < N; i++) {
            cin >> a[i];
        }
        int res = INF;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                res = min(res, abs(a[i] - a[j]));
            }
        }
        cout << res << endl;
    }
    return 0;
}

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

using namespace std;

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

    int n;

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

        int ans = a[n - 1] - a[0];
        for (int i = 0; i < n - 1; ++i)
            for (int j = i + 1; j < n; ++j)
            ans = min(ans, a[j] - a[i]);

        cout << ans << '\n';
    }

    return 0;
}

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

vector<int> v;

int main(){
while(1){	
	
	int n;
	cin >> n;
	if(n == 0) break;
	for(int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	
	sort(v.begin(), v.end());
	
	int ans = 99999999;
	for(int i=0; i<n-1; i++){
		ans = min(ans, abs(v[i] - v[i+1]));
	}
	
	cout << ans << endl;
	v.clear();
	
}//end	
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)

int main(void){
	int n;
	while(cin>>n,n){
		vector<int> a(n);
		rep(i,n)cin>>a[i];
		sort(a.begin(),a.end());
		int dif=INT_MAX;
		rep(i,n-1)dif=min(dif,a[i+1]-a[i]);
		cout<<dif<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long 
#define Rep(i, N) for(int i = 0; i < N; i++)

signed main()
{
  int N;

  while(cin >> N, N) {

    int A[1005];
    
    Rep(i, N) cin >> A[i];

    sort(A, A + N);
    
    int minv = 1LL << 60;

    Rep(i, N - 1) {
      minv = min(minv, A[i + 1] - A[i]);
    }

    cout << minv << endl;

  }

  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>

using LL = long long;
using namespace std;

int N;
int A[123456];


int main() {
	while (cin >> N, N) {
		for (int i = 0; i < N; ++i) {
			cin >> A[i];
		}
		sort(A, A + N);
		int ans = 123456789;
		for (int i = 1; i < N; ++i) {
			ans = min(ans, A[i] - A[i - 1]);
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
    int n;
    
    while(1){
        cin>>n;
        if(n==0){
        return 0;
        }
        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin>>a.at(i);
        }
        sort(a.begin(),a.end());
    
        vector<int> ans(n-1);
        for(int i=0;i<n-1;i++){
            ans.at(i)=a.at(i+1)-a.at(i);
        }
        sort(ans.begin(),ans.end());
        cout<<ans.at(0)<<endl;
    }
}

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

int main(void){
  int n;
  int a[1000]={};
  int min=1000000;
  cin>>n;
  while(n!=0){
    min=1000000;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i!=j){
	  int sa;
	  if(0>(a[i]-a[j])){
	    sa=a[j]-a[i];
	  }else{
	    sa=a[i]-a[j];
	  }
	  if(sa<min)sa=min;
	}
      }
    }
    cout<<min<<endl;
    cin>>n;
  }
}

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

int n;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		cin >> n;
		if(n == 0) return 0;
		vector<int> a;
		readVector(n, a);
		sort(a.begin(), a.end());
		int ans = 1e9+7;
		for(int i=1; i<n; ++i)
			ans = min(ans, a[i] - a[i-1]);
		cout << ans << "\n";
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n[50000];
int a[50000][1000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int j=0;
    while(true){
        cin >> n[j];
        if(n[j]==0){
            break;
        }
    for (int i = 0; i < n[j]; i++)
        cin >> a[j][i];
    j++;
    }
    for(int i=0;i<j;i++){
        sort(a[i],a[i]+n[i]);
    }
    int ans[j];
    for(int i=0;i<j;i++){
        ans[i]=INF;
    }
    for(int i=0;i<j;i++){
        int temp=INF;
        for(int k=0;k<n[i]-1;k++){
            int sub=a[i][k+1]-a[i][k];
            temp=min(temp,sub);
        }
        ans[i]=temp;
    }
    for(int i=0;i<j;i++)
    cout << ans[i] << "\n";
}

C++: //#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int n;
  vector<int> a;

  while (cin >> n, n) {
    a.resize(n);
    rep (i, n) cin >> a[i];

    sort(a.begin(), a.end());
    int ans = 10000;

    rep (i, n-1) {
      ans = min(ans, a[i+1] - a[i]);
    }

    cout << ans << endl;
  }

  return 0;
}