문제
풀이
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
bool solve(void) {
int n; cin >> n;
if (n == 0) return false;
vector<int> a(n);
for (int i=0; i<n; i++) cin >> a[i];
sort(a.begin(), a.end());
int ans = 1e9;
for (int i=1; i<n; i++) {
ans = min(ans, a[i] - a[i-1]);
}
cout << ans << "\n";
return true;
}
int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
while (solve());
return 0;
}