#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; stack in, out, insum, outsum; public: SWAG() { insum.emplace(G::e()); outsum.emplace(G::e()); } void push(const T& v){ insum.push(G::f(insum.top(), v)); in.emplace(v); } void pop(){ if(out.empty()){ do { out.emplace(in.top()); outsum.emplace(G::f(in.top(), outsum.top())); in.pop(); insum.pop(); }while(!in.empty()); } out.pop(); outsum.pop(); } T fold(){ return G::f(outsum.top(), insum.top()); } }; 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; }