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
}

Python: flg = True
while flg:
    n = int(input())
    if n == 0:
        flg = False
    a = list(map(int, input().split()))
    l = list()

    for i in range(0, n):
        for j in range(0,n):
            if i == j:
                continue
            l.append(abs(a[i]-a[j]))
    if l == []:
        continue
    print(min(l))

Python: 
while True:
    min = 1000000
    n =(int)(input())
    if n==0:
        break
    a = list(map(int, input().split()))

    for i in range (n-1):
        for j in range (i+1,n):
            num = a[i]-a[j]
            if min>abs(num):
                min = abs(num)
    print(min)

C++: #include<iostream>
#include<vector>
#include<list>
#include<algorithm>
using namespace std;
int main(void){
    int n;
    while(1){
cin>> n;
if(n==0)break;
vector<int> a(n);
for(int i=0;i<n;i++)
cin>>a[i];
sort(a.begin(),a.end());
int min=a[1]-a[0];
for(int i=1;i<n;i++){
if(a[i]-a[i-1]<min)
min=a[i]-a[i-1];
}
cout<<min<<endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    while(N){
        vector<int> V(N);
        rep(i,0,N)cin >> V[i];
        sort(V.begin(), V.end());
        int mind = INF;
        rep(i,1,N)mind = min(mind, V[i] - V[i-1]);
        cout << mind << endl;
        cin >> N;
    }
}

C++: #include <iostream>
#include <cstdlib>

int main(){
	int n;
	while(1){
		std::cin >> n;
		if(n==0) break;
		long a[n];
		for(int i=0;i<n;i++) std::cin >> a[i];
		long min = 2000000;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				min=std::min(min,std::abs(a[i]-a[j]));
			}
		}
		std::cout << min << std::endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
int x,y[x],min1=y[0],min2=y[0];
while(1){
cin>>x;
if (x=0)break;
for(int i=0;i<x;i++){
cin>>y[i];
if(y[i]<=min1){
min1=y[i];
min2=min1;}
}
cout<<min2-min1<<endl;
}
return 0;
}

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

int n;
int a[1000];

int main() {
	while (cin >> n) {
		if (!n) break;
		for (int i = 0; i < n; i++) cin >> a[i];
		sort(a, a + n);
		
		int ans = 1145141919;
		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;

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

C++: #include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int n;
  while(cin>>n,n){
    vector<int> x(n);
    REP(i,n)cin>>x[i];
    sort(ALL(x));
    int ans=INF;
    REP(i,x.size()-1){
      ans=min(ans,x[i+1]-x[i]);
    }
    cout<<ans<<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];

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

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

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

    return 0;
}

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

using namespace std;

int main() {
  int t, n, k, x, ans,a;

  while(1) {
    vector<int> point;
    cin >> n;

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

    sort(point.begin(),point.end());
    reverse(point.begin(),point.end());

    t = point[0];

    for(int i = 1; i < n; ++i) {
      k = point[i];
      if(i == 1){
        ans = t - k;
      }
      else {
        a = t - k;
        if(ans > a){
          ans = a;
        }
      }
      t = k;
    }

    cout << ans << endl;
  }

  return 0;
}

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;
    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 <iostream>
# include <algorithm>
using namespace std;

int main() {
    int n; cin >> n;
    while (n != 0) {
        int a[n] = {}; for (int i = 0; i < n; ++i) cin >> a[i];
        
        int min_diff = 1000000;
        for (int first = 0; first < n; ++first) {
            for (int second = first + 1; second < n; ++second) {
                int diff = abs(a[first] - a[second]);
                min_diff = min(min_diff, diff);
            }
        }
        cout << min_diff << endl;
        
        cin >> n;
    }
    return 0;
}

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 <iostream>
#include <cstdlib>
using namespace std;

int main(void){
  int n,i,j,a[1000],s=0,min,l,c,d;
  while(1){
    min = 1000000;
    cin >> n;
    if (n == 0)
        break;
    for (i=0;i<n;i++){
        cin >> l;
        a[i] = l;
    }
    for(i=0;i<n;i++){
      for(j=i+1;j<n;j++){
        s = abs(a[i] - a[j]);
        if(min > s)
          min = s;
      }
    }
    cout << min << endl;
  }
}

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

using namespace std;

int main() {
    int n;
    while (cin >> n, n != 0) {
        vector<int> a(n);
        for (int& x : a) {
            cin >> x;
        }

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

        int mini = 1 << 25;

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

        cout << mini << endl;
    }
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#define SEISEKI 1000001

using namespace std;

int main() {
	while (1) {
		int n,data;
		int ans=SEISEKI;
		vector<int> a;

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

		sort(a.begin(), a.end());	//昇順

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