#include using namespace std; using ll = long long; #define SPEED cin.tie(0);ios::sync_with_stdio(false); class Gcd{ public: inline static long long impl(long long n, long long m) { static constexpr long long K = 5; long long t,s; for(int i = 0; t = n - m, s = n - m * K, i < 80; ++i) { if(t= m * K) n = s; } } return impl(m, n % m); } inline static long long pre(long long n, long long m) { long long t; for(int i = 0; t = n - m, i < 4; ++i) { (t < m ? n=m,m=t : n=t); if(!m) return n; } return impl(n, m); } inline static long long gcd(long long n, long long m) { return (n>m ? pre(n,m) : pre(m,n)); } inline static constexpr long long pureGcd(long long a, long long b) { return (b ? pureGcd(b, a % b):a); } inline static constexpr long long lcm(long long a, long long b) { return (a*b ? (a / gcd(a, b)*b): 0); } inline static constexpr long long extGCD(long long a, long long b, long long &x, long long &y) { if (b == 0) return x = 1, y = 0, a; long long d = extGCD(b, a%b, y, x); return y -= a / b * x, d; } }; template class Swag{ public: using TypeNode = typename Operator::TypeNode; stack> pre,suf; Swag() { // do nothing } TypeNode fold() { TypeNode res = Operator::unit_node; if(pre.size()) res = Operator::funcNode(res,pre.top().second); if(suf.size()) res = Operator::funcNode(res,suf.top().second); return res; } void push(TypeNode val) { TypeNode acc = val; if(suf.size()) acc = Operator::funcNode(acc,suf.top().second); suf.emplace(val,acc); } void pop() { if(pre.empty()) { TypeNode acc = Operator::unit_node; while(suf.size()) { auto [val,_] = suf.top(); suf.pop(); acc = Operator::funcNode(acc,val); pre.emplace(val,acc); } } else{ pre.pop(); } } }; template struct nodeGCD { using TypeNode = T; inline static constexpr TypeNode unit_node = 0; inline static constexpr TypeNode funcNode(TypeNode l,TypeNode r){return Gcd::gcd(l,r);} }; // solution by binary search in arbitary range on disjn sparse table int main() { SPEED ll N; cin >> N; vector A(N+1,1); for(int i = 0; i < N; ++i) cin >> A[i]; Swag> swag; ll ans=0; int r=1; for(int i=0; i