#include using namespace std; #define DEBUG(x) cerr<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair template pair operator+(const pair &s, const pair &t) { return pair(s.first + t.first, s.second + t.second); } template pair operator-(const pair &s, const pair &t) { return pair(s.first - t.first, s.second - t.second); } template ostream& operator<<(ostream& os, pair p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--) #define rrep1(i,n) for(int i=(int)(n);i>0;i--) #define REP(i,a,b) for(int i=a;i bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const long double pi = 3.1415926535897932384626433832795028841971L; #define Sp(p) cout< a) { swap(a, b); } if (b == 0) return a; ll r = a%b; while (r != 0) { a = b; b = r; r = a%b; } return b; } // https://ei1333.github.io/algorithm/sparse-table.html template< typename T > struct SparseTable { vector< vector< T > > st; using F = function; F f; SparseTable() {} SparseTable(const vector< T > &v, const F &f) :f(f) { int b = 0; while((1 << b) <= v.size()) ++b; st.assign(b, vector< T >(1 << b)); for(int i = 0; i < v.size(); i++) { st[0][i] = v[i]; } for(int i = 1; i < b; i++) { for(int j = 0; j + (1 << i) <= (1 << b); j++) { st[i][j] = f(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]); } } } inline T query(int l, int r) // [l, r) { int b = 32 - __builtin_clz(r - l) - 1; return (f(st[b][l], st[b][r - (1 << b)])); } }; template< typename Semigroup > struct DisjointSparseTable { using F = function< Semigroup(Semigroup, Semigroup) >; const F &f; vector< vector< Semigroup > > st; DisjointSparseTable(const vector< Semigroup > v, const F f) : f(f) { int b = 0; while((1 << b) <= v.size()) ++b; st.resize(b, vector< Semigroup >(v.size(), Semigroup())); for(int i = 0; i < v.size(); i++) st[0][i] = v[i]; for(int i = 1; i < b; i++) { int shift = 1 << i; for(int j = 0; j < v.size(); j += shift << 1) { int t = min(j + shift, (int) v.size()); st[i][t - 1] = v[t - 1]; for(int k = t - 2; k >= j; k--) st[i][k] = f(v[k], st[i][k + 1]); if(v.size() <= t) break; st[i][t] = v[t]; int r = min(t + shift, (int) v.size()); for(int k = t + 1; k < r; k++) st[i][k] = f(st[i][k - 1], v[k]); } } } Semigroup query(int l, int r) { if(l >= --r) return st[0][l]; int p = 31 - __builtin_clz(l ^ r); return f(st[p][l], st[p][r]); } }; signed main() { fio(); int n; cin >> n; vl a(n); rep (i, n) { cin >> a[i]; } DisjointSparseTable spa(a, gcd); ll ans = 0; rep (i, n) { if (a[i] == 1) { ans += n - i; continue; } if (spa.query(i, n) != 1) continue; int ng = n, ok = i + 1; while (ok + 1 < ng) { int mid = (ng + ok) / 2; if (spa.query(i, mid) == 1) ng = mid; else ok = mid; } ans += n + 1 - ng; } cout << ans << endl; }