#include using namespace std; template struct Segtree { int n, n_org; T e; vector dat; typedef function Func; Func f; Segtree(){} Segtree(int n_input, Func f_input, T e_input){ initialize(n_input, f_input, e_input); } void initialize(int n_input, Func f_input, T e_input){ n_org = n_input; f = f_input; e = e_input; n = 1; while(n < n_input) n <<= 1; dat.assign(2*n-1, e); } void build(vector& A){ for(int k=0; k=0; k--) dat[k] = f(dat[2*k+1], dat[2*k+2]); } void update(int k, T a){ k += n - 1; dat[k] = a; while(k > 0){ k = (k - 1)/2; dat[k] = f(dat[2*k+1], dat[2*k+2]); } } T get(int k){ return dat[k+n-1]; } T between(int a, int b){ return query(a, b+1, 0, 0, n); } T query(int a, int b, int k, int l, int r){ if(r<=a || b<=l) return e; if(a<=l && r<=b) return dat[k]; T vl = query(a, b, 2*k+1, l, (l+r)/2); T vr = query(a, b, 2*k+2, (l+r)/2, r); return f(vl, vr); } }; int main(){ int N; cin >> N; vector A(N); for(int i=0; i> A[i]; Segtree st(N, [](auto a, auto b){ return gcd(a, b); }, 0); st.build(A); int r = 0; int64_t ans = 0; for(int l=0; l