#include using namespace std; // V = val, R = ret, F = function template struct SlidingWindow { const F &f; const R &id; stack> front, back; SlidingWindow(const F &f, const R &id) : f(f), id(id) { } size_t size() const { return front.size() + back.size(); } bool empty() const { return size() == 0; } void emplace(const V &val) { if (back.empty()) back.emplace(val, val); else back.emplace(val, f(back.top().second, val)); } void pop() { assert(!empty()); if (front.empty()) { while (!back.empty()) { auto [v, w] = back.top(); back.pop(); w = front.empty() ? v : f(front.top().second, v); front.emplace(v, w); } } front.pop(); } template T fold(const function &q) { auto rf = front.empty() ? id : front.top().second; auto rb = back.empty() ? id : back.top().second; return q(rf, rb); } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin >> N; using D = long long; function g = [&](D a, D b) { if (b == 0LL) return a; if (a % b) return g(b, a % b); return b; }; SlidingWindow SW(g, 0LL); long long Ans = 0; for (int i = 0; i < N; i++) { long long A; cin >> A; SW.emplace(A); while (!SW.empty() && SW.fold(g) == 1) { Ans += N - i; SW.pop(); } } cout << Ans << endl; return 0; }