#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define endl codeforces #define ALL(v) std::begin(v), std::end(v) #define ALLR(v) std::rbegin(v), std::rend(v) using ll = std::int64_t; using ull = std::uint64_t; using pii = std::pair; using tii = std::tuple; using pll = std::pair; using tll = std::tuple; template using vec = std::vector; template using vvec = vec>; template const T& var_min(const T &t) { return t; } template const T& var_max(const T &t) { return t; } template const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); } template const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); } template void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } template T make_v(T init) { return init; } template auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec(s, v); } template struct multi_dem_array { using type = std::array::type, Head>; }; template struct multi_dem_array { using type = std::array; }; template using mdarray = typename multi_dem_array::type; namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; } ssize_t ceil_pow2(ssize_t s) { ssize_t ret = 1; while (ret < s) ret *= 2; return ret; } struct SparseTable { vvec table; vec bsz; ll op(ll a, ll b) { return (a && b ? std::gcd(a, b) : std::max(a, b)); } SparseTable(const vec &av) { ll sz = ceil_pow2(av.size()); table = make_v(0, sz, 20); bsz.resize(sz + 1); for (ll i = 0, j = 1; j <= sz; i++, j *= 2) bsz[j] = i; for (ll i = 1; i <= sz; i++) chmax(bsz[i], bsz[i - 1]); for (ll i = 0; i < av.size(); i++) table[i][0] = av[i]; for (ll i = 0; i + 1 < 20; i++) for (ll j = 0; j < sz; j++) { ll f = j; ll t = std::min(sz - 1, f + (1ll << i)); table[j][i + 1] = op(table[j][i], table[t][i]); } } ll query(ll l, ll r) { ll len = r - l; ll idx = bsz[len]; ll offset = 1ll << idx; return op(table[l][idx], table[r - offset][idx]); } }; int main() { ll n; std::cin >> n; vec av(n); for (ll &e : av) std::cin >> e; SparseTable table(av); ll ans = 0; for (ll i = 0; i < n; i++) { if (1 < table.query(i, n)) break; ll ok = n, ng = i; while (1 < std::abs(ok - ng)) { ll mid = (ok + ng) / 2; (table.query(i, mid) == 1 ? ok : ng) = mid; } ans += n - ng; } std::cout << ans << '\n'; return 0; }