#pragma GCC optimize("O3", "unroll-loops") #include using namespace std; #define ll long long #define ld long double inline ll gcd(ll a, ll b){ if (b > a) return gcd(b, a); if (b == 0) return a; return gcd(b, a % b); } template struct SegmentTree { private: int sz, n; vector data; function f; T identity_element; public: /* constructor */ SegmentTree( vector& v, // initial data T identity_element, // identity element function f // operation ) { sz = v.size(); n = 1; while (n < sz) n <<= 1; this->f = f; this->identity_element = identity_element; data.resize(2 * n - 1, identity_element); for (int i = 0; i < sz; ++i) data[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; --i) data[i] = f(data[2 * i + 1], data[2 * i + 2]); } /* update query */ void update(int idx, const T val) { idx += n - 1; data[idx] = val; while (idx) { idx = (idx - 1) >> 1; data[idx] = f(data[2 * idx + 1], data[2 * idx + 2]); } } /* get query */ T get(int left, int right, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; if (r <= left || right <= l) return identity_element; if (left <= l && r <= right) return data[k]; T val_l = get(left, right, 2 * k + 1, l, (l + r) / 2); T val_r = get(left, right, 2 * k + 2, (l + r) / 2, r); return f(val_l, val_r); } }; int main(void){ int N; scanf("%d", &N); vector A(N); for (int i = 0; i < N; ++i) scanf("%lld", &(A[i])); SegmentTree seg( A, 0LL, [](ll a, ll b){ return gcd(a, b); } ); ll res = 0; for (int i = 0; i < N; ++i){ if (seg.get(i, N) > 1) continue; if (A[i] == 1){ res += N - i; continue; } int ng = i + 1, ok = N; while (ok - ng > 1){ int mid = (ok + ng) / 2; if (seg.get(i, mid) > 1) ng = mid; else ok = mid; } res += N - ok + 1; } cout << res << endl; return 0; }