#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int a[1000000];
int n;

int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    
    sort(a, a+n);
    int kq = 1000000000;
    for (int i = 0; i < n-1; ++i) {
        int x = abs(a[i] - a[i+1]);
        if (x < kq) {
            kq = x;
        }
    }
    
    cout<<kq;
    return 0;
}