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>
#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++: #define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#define fn auto
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
void iput(int input) {put(input);}
void lput(long long input) {put(input);}

fn main() -> int {
  int n, in, prev, min, sa;
  vector<int> input;
  while(true){
    cin >> n;
    if(n != 0){
      for(int i=0; i<n; i++){
        cin >> in;
        input.push_back(in);
      }
      sort(input.begin(), input.end());
      min = 1000000;
      for(int i=1; i<n; i++){
        sa = abs(input[i-1] - input[i]);
        min = min > sa ? sa : min;
      }
      iput(min);
    }else{
      break;
    }
  }
}

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

vector<int> ans;

int main(){
  int n;

  while(cin >> n,n){
    vector<int> val;
    int ans_t=1000;
    for(int i=0; i<n; ++i){
      int tmp;
      cin >> tmp;
      val.push_back(tmp);
    }
    sort(val.begin(),val.end(),greater<int>());
    for(int i=0; i<n-1; ++i){
      int tmp = val[i]-val[i+1];
      if(ans_t > tmp){
	ans_t = tmp;
      }
    }
    ans.push_back(ans_t);
  }

  for(auto i:ans){
    cout << i << endl;
  }
  return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int n;
  while(cin >> n) {
    if(n == 0) return 0;
    int a[n];
    FOR(i,0,n) scanf("%d", a+i);
    sort(a, a + n);
    int ans = 1000000000;
    FOR(i,0,n-1) ans = min(ans, a[i+1] - a[i]);
    cout << ans << endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include<algorithm>
#include<vector>
#include <iostream>
using namespace std;
int n,a[1005];
int main(){
  while(1){
    cin >> n; if(n==0) return 0;
    for(int i=1;i<=n;i++) cin >> a[i];
    sort(a+1,a+n+1);
    int res = 10000000;
    for(int i=2;i<=n;i++) res = min(res,a[i]-a[i-1]);
    cout << res << endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
	int n, min = -1;
	vector<int> v;
	for (;;) {
		cin >> n;
		if (n == 0) break;
		v.resize(n);
		for (int i = 0; i < n; i++) cin >> v[i];

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

		for (int i = 0; i < n - 1; i++) {
			if (min == -1)min = v[i + 1] - v[i];
			else if (min > v[i + 1] - v[i]) min = v[i + 1] - v[i];
		}
		cout << min << endl;
		min = -1;
	}
}

C++: void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  while(1){
    int n; rd(n); if(n==0) break;
    auto a=readln.split.to!(int[]);
    sort(a);
    int mn=1_000_000_000;
    foreach(i; 0..(n-1)) mn=min(mn, a[i+1]-a[i]);
    writeln(mn);
  }
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) write(e, " ");
  writeln();
}

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

using namespace std;
typedef long long ll;

int ar[50000];

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

		sort(ar, ar + n);

		int ans = 99999999;

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

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define PI       3.1415926535897932384626433832795028841971
#define INF 1000000000
#define EPS      1e-10
#define MOD      1000000007
using namespace std;
typedef long long ll;
typedef pair<double,double> P;
typedef pair<double,P> PQ;

int n;
int a[100000];

int main(){
    while(cin >> n){
        if(n == 0) break;
        memset(a,0,sizeof(a));
        rep(i,n) cin >> a[i];
        sort(a,a+n);
        int ans = INF;
        for(int i = 1; i < n; i++) ans = min(ans,a[i]-a[i-1]);
        cout << ans << endl;
    }
}

C++: #include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    while(1){
        ll n; cin >> n;
        if(!n) break;
        vl a(n); rep(i,n) cin >> a[i];
        sort(all(a));
        ll ans = linf;
        rep(i,n-1){
            chmin(ans,a[i+1]-a[i]);
        }
        cout << ans << endl;
    }
}