#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair Pr; ll N, X[100010]; int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> X[i]; } sort(X,X+N); int mi = 100000000; for (int i = 0; i < N-1; i++) { if (X[i+1] != X[i] && mi > X[i + 1] - X[i]) { mi = X[i + 1] - X[i]; } } if (mi != 100000000) cout << mi << endl; else cout << -1 << endl; return 0; }