import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    while (true) {
        int n;
        scan(n);
        if (!n) return;
        auto a = readln.split.to!(int[]);
        a.sort();
        int ans = 10^^7;
        foreach (i ; 0 .. n-1) {
            ans = min(ans, a[i+1] - a[i]);
        }

        writeln(ans);
    }
}

void solve(int n, int a, int b, int[] p) {
    int difmax, ans;

    foreach (i ; a .. b + 1) {
        if (difmax <= p[i-1] - p[i]) {
            difmax = p[i-1] - p[i];
            ans = i;
        }
    }

    writeln(ans);
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}