#include #include using namespace std; using namespace atcoder; typedef long long ll; typedef long double ld; typedef vector vi; typedef vector vvi; typedef vector vl; typedef vector vvl; typedef vector vd; typedef vector vvd; typedef vector vc; typedef vector vvc; typedef vector vs; typedef vector vvs; typedef vector vb; typedef vector vvb; typedef pair pii; typedef pair pll; typedef modint998244353 mint; // atcoder typedef vector vm; // atcoder typedef vector vvm; // atcoder template using pqmax = priority_queue, less>; // 昇順 template using pqmin = priority_queue, greater>; // 降順 #define overload4(_1,_2,_3,_4,name,...) name #define REP1(n) for(ll i=0;in-1, 2: i,0->n-1, 3: i,a->b-1, 4: i,a->b-1,c #define REP(...) overload4(__VA_ARGS__, REP4, REP3, REP2, REP1)(__VA_ARGS__) #define RREP1(n) for(ll i=n;i>0;i--) #define RREP2(i,n) for(ll i=n;i>0;i--) #define RREP3(i,a,b) for(ll i=a;i>b;i--) #define RREP4(i,a,b,c) for(ll i=a;i>b;i-=c) // 1: n->1, 2: i,n->1, 3: i,a->b+1, 4: i,a->b+1,c #define RREP(...) overload4(__VA_ARGS__, RREP4, RREP3, RREP2, RREP1)(__VA_ARGS__) #define REPA(i, a) for(auto&&i:a) #define ALL(x) x.begin(), x.end() #define SZ(x) (int)x.size() templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (bconstexpr auto min(T... a){ return min(initializer_list>{a...}); } templateconstexpr auto max(T... a){ return max(initializer_list>{a...}); } templatevoid input(T&... a){ (cin >> ... >> a); } void print(){ cout << endl; } templatevoid print(const T &a, const Ts &...b){ cout << a; (cout << ... << (cout << ' ', b)); cout << endl; } void debug(){ cerr << endl; } templatevoid debug(const T &a, const Ts &...b){ cerr << a; (cerr << ... << (cerr << ' ', b)); cerr << endl; } template vector make_vector(const size_t &a, const T &b) { return vector(a, b); } template auto make_vector(const size_t &a, const Ts &...b) { return vector(a, make_vector(b...)); } constexpr int MOD = 998244353; constexpr int inf = 1001001001; constexpr ll INF = 1001001001001001001; int main(){ // cin.tie(0); // ios::sync_with_stdio(0); // cout << fixed << setprecision(20); int N; cin >> N; vl A(N); REP(i, N) cin >> A[i]; set st; st.emplace(-INF); st.emplace(INF); ll g = 0; REP(i, N){ if (st.count(A[i]) == 0){ auto p = st.upper_bound(A[i]); ll right = *p; p--; ll left = *p; if (left != -INF){ g = gcd(g, A[i] - left); } if (right != INF){ g = gcd(g, right - A[i]); } } print(g); st.emplace(A[i]); } return 0; }