#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int N = 1010;
int n;
int a[N];
int main()
{
cin>>n;
for(int i = 0; i<n; i++) cin>>a[i];
sort(a,a+n);
int ans = 100010;
for(int i = 1; i+1<n; i++)
{
ans = min(ans,a[i]-a[i-1]);
ans = min(ans,a[i+1]-a[i]);
}
cout<<ans;
return 0;
}