#include #include using namespace std; int main() { int N; int X[100000]; int swap; int min[2] = { 1000001,0 }; cin >> N; for (int i = 0; i < N; i++) cin >> X[i]; sort(X, X + N); for (int i = 0; i < N; i++) { if (X[i] != X[i - 1]) min[1] = X[i] - X[i - 1]; if (min[1] < min[0]) min[0] = min[1]; if (min[0] == 1) break; } if (min[0] > 1000000) min[0] = -1; cout << min[0] << endl; }