#include using namespace std; using lint = long long; const lint inf = 1LL << 60; const lint mod = 1000000007; // greatest common divisor and least common multiple // gcd is calculated by Euclidean Algorithm // lcm = m * n / gcd(m,n) template T gcd(T a, T b) { if (a < b) return gcd(b, a); if (b == 0) return a; T r; while ((r = a % b)) { a = b; b = r; } return b; } template T lcm(T m, T n) { if ((0 == m) || (0 == n)) return 0; return ((m / gcd(m, n)) * n); } // 0-indexed bottom up Segment Tree // UNIT is the identity element of operation func template struct SegmentTree { using F = function; int n; vector dat; F func; T UNIT; SegmentTree(int n_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) { n = 1; // full binary tree: num of leaves = n = 2^k >= n_ while (n < n_) n *= 2; dat.assign(2 * n - 1, UNIT); } SegmentTree(vector v_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) { n = 1; int nv = v_.size(); while (n < nv) n *= 2; dat.assign(2 * n - 1, UNIT); for (int i = 0; i < nv; ++i) { dat[n - 1 + i] = v_[i]; } for (int i = n - 2; i >= 0; --i) { dat[i] = func(dat[2 * i + 1], dat[2 * i + 2]); } } void update(int k, T a) { // leaves are at index n-1 to 2*n-2 k += n - 1; dat[k] = a; while (k > 0) { // k -> parent node k = (k - 1) / 2; // func(child nodes) dat[k] = func(dat[2 * k + 1], dat[2 * k + 2]); } } // get result of func() in [l, r) T query(int l, int r) { l += n - 1; r += n - 1; T retl = UNIT, retr = UNIT; while (l < r) { if ((l & 1) == 0) retl = func(retl, dat[l]); if ((r & 1) == 0) retr = func(dat[r - 1], retr); l = l / 2; r = (r - 1) / 2; } return func(retl, retr); } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); lint n; cin >> n; vector a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } lint unit = 0; auto f = [&](lint l, lint r) { if (l == 0) return r; else if (r == 0) return l; return gcd(l, r); }; SegmentTree seg(a, f, unit); int r = 1; lint g = a[0]; lint ret = 0; for (int i = 0; i < n; ++i) { if (r <= i) r = i + 1; g = seg.query(i, r); while (r < n && g != 1) { g = gcd(g, a[r]); r++; } if (g != 1) continue; ret += n - r + 1; } cout << ret << "\n"; return 0; }