//Bai 21
#include<bits/stdc++.h>
using namespace std;
#define el "\n"
#define ll long long
#define ull unsigned long long
#define se second
#define fi first
#define be begin()
#define en end()
#define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
int n;
void Run()
{
cin >> n;
ll a[n];
for(auto &x : a) cin >> x;
sort(a, a + n);
ll ans = abs(a[1] - a[0]);
for(int i = 2; i < n; i++) ans = min(ans, a[i] - a[i - 1]);
cout << ans;
}
int main()
{
Faster;
Run();
return 0;
}
Ly9CYWkgMjEKCiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZWwgIlxuIgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIHVsbCB1bnNpZ25lZCBsb25nIGxvbmcKI2RlZmluZSBzZSBzZWNvbmQKI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIGJlIGJlZ2luKCkKI2RlZmluZSBlbiBlbmQoKQojZGVmaW5lIEZhc3RlciBjaW4udGllKDApOyBjb3V0LnRpZSgwKTsgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKaW50IG47CnZvaWQgUnVuKCkKewogICAgY2luID4+IG47CiAgICBsbCBhW25dOwogICAgZm9yKGF1dG8gJnggOiBhKSBjaW4gPj4geDsKICAgIHNvcnQoYSwgYSArIG4pOwogICAgbGwgYW5zID0gYWJzKGFbMV0gLSBhWzBdKTsKICAgIGZvcihpbnQgaSA9IDI7IGkgPCBuOyBpKyspIGFucyA9IG1pbihhbnMsIGFbaV0gLSBhW2kgLSAxXSk7CiAgICBjb3V0IDw8IGFuczsKfQppbnQgbWFpbigpCnsKICAgIEZhc3RlcjsKICAgIFJ1bigpOwogICAgcmV0dXJuIDA7Cn0KCg==