Simulation!!
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;
int n;
int main(void) {
scanf("%d", &n);
int a[n];
for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
sort(a, a + n);
int ans = INT_MAX;
for (int i = 1; i < n; ++i)
ans = min(ans, a[i] - a[i - 1]);
printf("%d\n", ans);
return 0;
}