#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int n;
int a[1003];
int dp[1003];
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
}
sort(a+1, a+n+1);
for(int i = 1; i <= n; ++i) {
dp[i] = 2e9;
}
for(int i = 2; i <= n; ++i) {
int maximum = a[i];
int minimum = a[i];
for(int j = i-1; j >= 1; --j) {
maximum = max(maximum, a[j]);
minimum = min(minimum, a[j]);
dp[i] = min(dp[i], max(dp[j-1], maximum-minimum));
}
}
cout << dp[n] << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Y3N0ZGlvPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG47CmludCBhWzEwMDNdOwppbnQgZHBbMTAwM107CgppbnQgbWFpbigpIHsKICAgIGZyZW9wZW4oImlucHV0LnR4dCIsICJyIiwgc3RkaW4pOwogICAgZnJlb3Blbigib3V0cHV0LnR4dCIsICJ3Iiwgc3Rkb3V0KTsKCiAgICBjaW4gPj4gbjsKICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CiAgICAgICAgY2luID4+IGFbaV07CiAgICB9CiAgICBzb3J0KGErMSwgYStuKzEpOwogICAgZm9yKGludCBpID0gMTsgaSA8PSBuOyArK2kpIHsKICAgICAgICBkcFtpXSA9IDJlOTsKICAgIH0KICAgIGZvcihpbnQgaSA9IDI7IGkgPD0gbjsgKytpKSB7CiAgICAgICAgaW50IG1heGltdW0gPSBhW2ldOwogICAgICAgIGludCBtaW5pbXVtID0gYVtpXTsKICAgICAgICBmb3IoaW50IGogPSBpLTE7IGogPj0gMTsgLS1qKSB7CiAgICAgICAgICAgIG1heGltdW0gPSBtYXgobWF4aW11bSwgYVtqXSk7CiAgICAgICAgICAgIG1pbmltdW0gPSBtaW4obWluaW11bSwgYVtqXSk7CiAgICAgICAgICAgIGRwW2ldID0gbWluKGRwW2ldLCBtYXgoZHBbai0xXSwgbWF4aW11bS1taW5pbXVtKSk7CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCBkcFtuXSA8PCBlbmRsOwoKICAgIHJldHVybiAwOwp9Cg==