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;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int n;
  while(true){
    cin >> n;
    if(n==0) break;
    std::vector<int> v;
    for(int i=0;i<n;i++){
      int a;cin >> a;v.push_back(a);
    }
    sort(v.begin(),v.end());
    int res=INF;
    for(int i=0;i<n-1;i++) res=min(res,v[i+1]-v[i]);
    cout << res << endl;
  }
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
#define INF 1000000
using namespace std;

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

C++: 
def solve(N):
    A = list(map(int, input().split()))
    ans = 1e9
    for i in range(N):
        for j in range(N):
            if i != j:
                d = abs(A[i] - A[j])
                if ans > d:
                    ans = d
    print(ans)

while True:
    N = int(input())
    if N > 0:
        solve(N)
    else:
        break

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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  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];
    sort(a.begin(), a.end());
    int res = 1e9;
    for (int i = 0; i < n - 1; i++) res = min(res, a[i + 1] - a[i]);
    cout << res << '\n';
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <math.h>
#include <algorithm>
using namespace std;

int n,ten[1003],ans;

int main(){
while(1){
	
	
	scanf("%d",&n);
	if(n == 0)break;
	for(int i = 0;i < n;i++){
		scanf("%d",&ten[i]);
	}
	
	ans = abs(ten[0]-ten[1]);
	
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			ans = min(ans,abs(ten[i]-ten[j]));
		}
	}
	
	printf("%d\n",ans);
	
}

return 0;

}

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

int d[1005];

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

        int min = 1 << 30;
        for(int i = 0; i < n; ++i)
        {
            for(int j = 0; j < n; ++j)
            {
                if(i == j)
                {
                    continue;
                }
                else
                {
                    min = std::min(min, std::abs(d[i] - d[j]));
                }
            }
        }
        printf("%d\n", min);
    }
    return 0;
}

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

using namespace std;

int main()
{
  int n;
  vector<int> vec_a;
  int diff;
  int diff_min;
  
  while (1) {
    cin >> n;
    if (n == 0) break;
    
    vec_a.clear();
    while (n--) {
      int a;
      cin >> a;
      vec_a.push_back(a);
    }
    
    sort(vec_a.begin(), vec_a.end());
    
    diff_min = 1000000;
    for (int i = 1; i != vec_a.size(); i++) {
      diff = vec_a.at(i) - vec_a.at(i - 1);
      if (diff < diff_min) diff_min = diff;
    }

    cout << diff_min << endl;
  }
}

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

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

int main(void){
  while(true){
    int n;
    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 ans = 10000000;
    for(int i = 1; i < n; i++){ ans = min(a[i] - a[i - 1], ans); }
    cout << ans << endl;
  }

  return 0;
}

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

using namespace std;

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

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

#define INF 1e9;

int main(){
  int n;
  while(true){
    cin >> n;
    if(n == 0)
      break;
    
    vector<int> a(n);
    for(int i=0; i<n; i++)
      cin >> a[i];

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

    cout << nmin << endl;
  }
             
  return 0;
}

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

int main(){
    while(true){
        int n;
        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 d = INF;
        for(int i=1;i<n;i++)
            d = min(d, a[i]-a[i-1]);
        
        cout << d << endl;
    }
    return 0;
}

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

int main(){
  while(true){
    int n;
    cin >> n;

    if(n==0)
     break;

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

    int dif = 1000001;

    for(int i=0; i<n-1; i++){
      for(int j=i+1; j<n; j++){
        int d = abs(a[i]-a[j]);

        if(d<dif){
          dif = d;
        }
      }
    }
    cout << dif << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(void)
{
        int i,j,num,diff;
            
        while(1){
                int min = 1000000;
                cin >> num;
                if(num == 0){ 
                        break;
                }   
                    
                vector<int> data(num);
                for(i = 0; i < num; i++){
                        cin >> data[i];
                }   
                    
                for(i = 0; i < num - 1; i++){
                        for(j = i + 1; j < num; j++){
                                diff = abs(data[i] - data[j]);
                                if(diff <= min){
                                        min = diff;
                                }   
                        }   
                }   
                cout << min <<endl;
        }   
        return 0;
}

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

int n, a[1000];

int main(){
	int mi;
	while (cin >> n && n != 0) {
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a, a + n);
		mi = a[1] - a[0];
		for (int i = 1; i < n - 1; i++) {
			if (a[i + 1] - a[i] < mi) {
				mi = a[i + 1] - a[i];
			}
		}
		cout << mi << endl;
	}

	return 0;
}