#include #include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using namespace std; template constexpr T INF = ::numeric_limits::max()/32*15+208; ll gcd_(ll x, ll y){ if(x < y) swap(x, y); while(y){ x %= y; swap(x, y); } return x; } template class SWAG { using T = typename G::T; vector in, out, insum, outsum; public: SWAG() : in(0), out(0), insum(1, G::e()), outsum(1, G::e()) {} void push(const T& v){ insum.push_back(G::f(insum.back(), v)); in.push_back(v); } void pop(){ if(out.empty()){ do { out.emplace_back(in.back()); outsum.emplace_back(G::f(in.back(), outsum.back())); in.pop_back(); insum.pop_back(); }while(!in.empty()); } out.pop_back(); outsum.pop_back(); } T fold(){ return G::f(outsum.back(), insum.back()); } }; struct Monoid { using T = ll; static T f(T a, T b) { return gcd_(a, b); } static T e() { return 0; } }; int main() { int n; cin >> n; vector v(n); for (auto &&k : v) scanf("%lld", &k); SWAG Q; ll ans = 0, val = 0; for (int i = 0; i < n; ++i) { Q.push(v[i]); while(Q.fold() == 1) Q.pop(), val++; ans += val; } cout << ans << "\n"; return 0; }