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++: // 2016-12-04
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	int n;
	int a[1000];
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a, a + n);
		int m = 1000000;
		for (int i = 1; i < n; i++) {
			m = min(m, a[i] - a[i - 1]);
		}
		cout << m << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, A[1000];
  while(scanf("%d", &N), N) {
    for(int i = 0; i < N; i++) scanf("%d", A + i);
    int ret = 114514;
    for(int i = 0; i < N; i++) for(int j = 0; j < i; j++) ret = min(ret, abs(A[i] - A[j]));
    printf("%d\n", ret);
  }
}

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

int main() {
	
	int n;
	int point[51000]; //データセットごとの点数
	int count = 0;
	
	while (1)
	{
		
		cin >> n;
		
		if(n == 0) break; // 0を入力されたら終了
		
		int a[n];
		count++;
		
		for (int i = 0; i < n; i++) std::cin >> a[i];
		
		// 配列を大きい順に並べ替える
		sort(a, a+n, greater<int>());
		
		int proa = 0;
		int d;
		//データセットごとの作業
		for (int i = 0; i < n; i++) {
			
			// 隣のデータとの差
			d = abs(proa - a[i]);
			
			// 初期値は最大点
			if(i == 0) point[count - 1] = a[0];
			
			if(d < point[count - 1]) point[count - 1] = d;
			
			proa = a[i];
		}
	}
	
	for (int i = 0; i < count; i++) {
		cout << point[i] << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<cstdlib>
using namespace std;
int main(){
	int n;
	int a[1000];

	while(1){
		cin>>n;

		if(n==0)
			break;

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

		int diff=1000000;

		for(int i=0;i<(n-1);i++){
			for(int j=i+1;j<n;j++){
				if(diff>abs(a[i]-a[j]))
					diff=abs(a[i]-a[j]);
			}
		}

		cout<<diff<<endl;
	
	}

	return 0;
}

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

using VI = vector<long>;

int main() {
  while (1) {
    long n;
    cin >> n;
    if (!n) {
      return 0;
    }
    VI v;
    for (int i = 0; i < n; i++) {
      long a;
      cin >> a;
      v.push_back(a);
    }
    sort(v.begin(), v.end());
    long diff = 1e9;
    for (int i = 1; i < n; i++) {
      diff = min(diff, v[i] - v[i - 1]);
    }
    cout << diff << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

int main(void){
    int n;
    while(cin>>n,n){
        vi s(n);
        int ans=1000000000;
        rep(i,n){
            cin>>s[i];
        }
        sort(all(s));
        rep(i,n-1){
            ans=min(ans,s[i+1]-s[i]);
        }
        cout<<ans<<endl;
    }
}

C++: #include <cstdio>
#include <cmath>

using namespace std;

int main()
{
	int n, a[1000], min, temp;

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

		min = 1000000;

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

		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < n; ++j)
			{
				if (j == i)
				{
					continue;
				}

				temp = abs(a[i] - a[j]);
				min = min > temp ? temp : min;
			}
		}

		printf("%d\n", min);
	}
}

C++: #include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int n, a[1000];
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    scanf("%d", &n);
    if(!n)break;
    rep(i, n)scanf("%d", a+i);
    sort(a, a + n);
    int res = 12345123;
    rep1(i, n)res = min(res, a[i] - a[i - 1]);
    pri(res);
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int a[n],i,j,k;
    for(i=0;i<n;i++) cin>>a[i];
    k=abs(a[1]-a[0]);
    for(i=0;i<n;i++)
      for(j=i+1;j<n;j++)
	k=min(k,abs(a[i]-a[j]));
    cout<<k<<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<cmath>
using namespace std;
int main(){
  int n,a[1001]={};
  while(1){
    int min=1000000;
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++) cin>>a[i];

    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
	  if(min>abs(a[i]-a[j]))min=abs(a[i]-a[j]);

    cout<<min<<endl;
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    while(n > 0){
        vector<int> a(n);
        for(int i=0; i<n; i++){
            cin >> a[i];
        }
        int ans = 101010101;
        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;
        cin >> n;
    }
}