#include #define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i)) #define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i)) #define rep(i, n) For((i), 0, (n)) #define rrep(i, n) rFor((i), (n), 0) #define fi first #define se second using namespace std; typedef long long lint; typedef unsigned long long ulint; typedef pair pii; typedef pair pll; template bool chmax(T &a, const T &b){if(a bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;} template T div_floor(T a, T b){ if(b < 0) a *= -1, b *= -1; return a>=0 ? a/b : (a+1)/b-1; } template T div_ceil(T a, T b){ if(b < 0) a *= -1, b *= -1; return a>0 ? (a-1)/b+1 : a/b; } constexpr lint mod = 1e9+7; constexpr lint INF = mod * mod; constexpr int MAX = 200010; template struct SWAG{ using P = pair; stack

st_front, st_back; function f; SWAG(function f_): f(f_){} int size(){ return st_front.size() + st_back.size(); } bool empty(){ return size() == 0; } T fold_all(){ if(st_front.empty()) return st_back.top().se; if(st_back.empty()) return st_front.top().se; return f(st_front.top().se, st_back.top().se); } void push(T a){ if(st_back.empty()) st_back.emplace(a, a); else st_back.emplace(a, f(st_back.top().se, a)); } void pop(){ if(!size()) return; if(!st_front.empty()) st_front.pop(); else{ while(!st_back.empty()){ P tmp=st_back.top(); if(st_front.empty()){ st_front.emplace(tmp.fi, tmp.fi); st_back.pop(); } else{ st_front.emplace(tmp.fi, f(tmp.fi, st_front.top().se)); st_back.pop(); } } st_front.pop(); } } }; int main(){ int n; scanf("%d", &n); lint a[n]; rep(i, n) scanf("%lld", &a[i]); auto f = [](lint p, lint q){return gcd(p, q);}; SWAG que(f); lint ans = 0; for(int l=0, r=1; l