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 abs(int x)
{
  if (x >= 0) return x;
  else return -x;
}

int main(void)
{
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break; 
    int a[n];
    for (size_t i = 0; i < n; i++)
      cin >> a[i];
    int min = 1000000;
    for (size_t i = 0; i < n; i++) {
      int first;
      first = a[i];
      for (size_t j = i + 1; j < n; j++) {
	int diff = abs(first - a[j]);
	if (diff < min)
	  min = diff;	
      }
    }
    cout << min << endl;
  }
  return true;

}

C++: #include<bits/stdc++.h>
using namespace std;
int n,a[10000];
int main(){
	while(true){
		cin>>n;if(n==0)break;for(int i=0;i<n;i++)cin>>a[i];
		sort(a,a+n);int minx=1000000;
		for(int i=0;i<n-1;i++){
			minx=min(minx,a[i+1]-a[i]);
		}
		cout<<minx<<endl;
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int a[1000];
int main(){
	int n;
	while(true){
		cin>>n;
		if(!n)break;
		for(int i=0;i<n;i++)cin>>a[i];
		sort(a,a+n);
		int ret=1145141919;
		for(int i=0;i<n-1;i++)ret=min(ret,a[i+1]-a[i]);
		cout<<ret<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	while (1) {
		int n,data;
		int ans=SEISEKI;

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

C++: #include<stdio.h>

int ov_abs(int a){
    return a>0 ? a : -a;
}

int score[1000];
int main(){
    int n;
    scanf("%d",&n);
    while(n!=0){
        int ans = 889464810;
        for(int i=0; i<n; i++){
            scanf("%d",&score[i]);
        }
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                int tmp = ov_abs(score[j]-score[i]);
                ans = ans > tmp ? tmp:ans;
            }
        }
        printf("%d\n",ans);
        scanf("%d",&n);
    }

    return 0;
}

C++: #include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    while(N != 0){
        vector<int> A(N);
        for(int i=0; i<N; i++){
            cin >> A[i];
        }
        int mx = inf;
        sort(A.begin(),A.end());
        for(int i=0; i<N-1; i++){
            chmin(mx,A[i+1]-A[i]);
        }
        cout << mx << endl;
        cin >> N;
    }
    return 0;
}

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

int main(){
    int n;
    while(scanf("%d",&n), n != 0){
        int a[1001]={0};
        for(int i=0;i<n;++i)scanf("%d ",&a[i]);
        int mini = INT_MAX;
        for(int i=0;i<n;++i){
            for(int j=i+1;j<n;++j){
                int d = abs(a[i] - a[j]);
                if(d < mini)mini = d;
            }
        }
        printf("%d\n",mini);
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define DEBUG(x) cerr << #x << " = " << x << endl

signed main() {
  ios::sync_with_stdio(false);
  while(true) {
    int N; cin >> N;
    if(N == 0) break;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    int ans = abs(A[1] - A[0]);
    REP(i,N) {
      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;

int main(){
	while(1){	
	int n,s[1000],sa,h;
	cin>>n;
	if(n==0) break;
	for(int i=0;i<n;i++)
		cin>>s[i];
	sa=s[1]-s[0];
	if(sa<0) sa=sa*(-1);
	for(int i=0;i<n-1;i++){
		for(int l=i+1;l<n;l++){
			h=s[l]-s[i];
			if(h<0) h=h*(-1);
			if(sa>=h) sa=h;
		}
	}
	cout<<sa<<endl;
	}	
    return 0;
}

C++: #include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>

int main()
{
  int n;
  while(scanf("%d",&n)==1){
      if(n==0){
          break;
      }
      else{
          int a[1010];
          for(int i=0;i<n;i++){
              scanf("%d",&a[i]);

          }
          int step = 10000000;
          for(int i=0;i<n-1;i++){
              for(int j=i+1;j<n;j++){
                  if(abs(a[i]-a[j])<step){
                      step = abs(a[i]-a[j]);
                  }
              }
          }
          printf("%d\n",step);

      }

  }


    return 0;
}

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

using namespace std;

int main(){
  int n;
  int data[1000]={};
  int a,b;
  int min;

  while(1)
    {
      cin >> n;
      if(n ==0)break;
      
      for(int i = 0;i<n;i++)
	{
	  cin >> data[i];
	}

      sort(data,data+n);

      min = data[1]-data[0];

      for(int j = n-1;j > 0;j--)
	{
	  a = data[j]-data[j-1];
	  if(a < min)
	    {
	      min = a;
	    }
	}
      cout << min << endl;
    }
}

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

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

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

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int n, a[SIZE];
  int ans = INF;
  
  scanf("%d", &n);
  if(n == 0) return false;
  for(int i=0;i<n;i++){
    scanf("%d", a+i);
  }
  sort(a, a+n);
  for(int i=1;i<n;i++)
    ans = min(ans, abs(a[i] - a[i-1]));
  

  printf("%d\n", ans);
  return true;
}

int main(){
  while(solve());
  
  return 0;
}