#include"bits/stdc++.h" using namespace std; #define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++) #define rep(i,n) REP((i),0,(n)) using ll = long long; using pii = pair; using pll = pair; using tp3 = tuple; using Mat = vector>; constexpr int INF = 1 << 28; constexpr ll INFL = 1ll << 60; constexpr int dh[4] = { 0,1,0,-1 }; constexpr int dw[4] = { -1,0,1,0 }; bool isin(const int H, const int W, const int h, const int w) { return 0 <= h && h < H && 0 <= w && w < W; } template T minch(T& l, T r) { return l = min(l, r); } template T maxch(T& l, T r) { return l = max(l, r); } template void output(const T& val) { cout << val << endl; } template void output(const vector& vec, const bool newline = false) { for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl; } template void output(const vector>& mat) { for (const auto& row : mat)output(row); } //ttp://beet-aizu.hatenablog.com/entry/2019/03/12/171221 template class SegmentTree { private: using F = function; // モノイド型 int n; // 横幅 F f; // モノイド T e; // モノイド単位元 vector data; public: // init忘れに注意 SegmentTree() {} SegmentTree(F f, T e) :f(f), e(e) {} void init(int n_) { n = 1; while (n < n_)n <<= 1; data.assign(n << 1, e); } void build(const vector& v) { int n_ = v.size(); init(n_); rep(i, n_)data[n + i] = v[i]; for (int i = n - 1; i >= 0; i--) { data[i] = f(data[(i << 1) | 0], data[(i << 1) | 1]); } } void set_val(int idx, T val) { idx += n; data[idx] = val; while (idx >>= 1) { data[idx] = f(data[(idx << 1) | 0], data[(idx << 1) | 1]); } } T query(int a, int b) { // [a,b) T vl = e, vr = e; for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) { if (l & 1)vl = f(vl, data[l++]); // unknown if (r & 1)vr = f(data[--r], vr); // unknown } return f(vl, vr); } }; // ============ template finished ============ int main() { ll N; cin >> N; vector A(N); rep(i, N)cin >> A[i]; auto f = [](ll a, ll b) {return gcd(a, b); }; SegmentTree seg(f, 0ll); seg.build(A); ll res = 0; rep(i, N) { if (A[i] == 1) { res += N - i; continue; } if (seg.query(i, N) != 1) { continue; } ll safe = N, out = i; while (abs(safe - out) > 1) { ll mid = (safe + out) / 2; ll tres = seg.query(i, mid); (tres == 1 ? safe : out) = mid; } res += N - out; } output(res); return 0; }