#include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; const ll MOD = 1000000007LL; template class SegmentTree { using F = function; int n; F f; T t; vector dat; public: SegmentTree(F f, T t) : f(f), t(t) {} void init(int n_) { n = 1; while (n < n_) n <<= 1; dat.assign(n << 1, t); } void build(const vector &v) { auto n_ = (int)v.size(); init(n_); for (int i = 0; i < n_; i++) dat[n + i] = v[i]; for (int i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); } void set_val(int k, T x) { dat[k += n] = x; while (k >>= 1) dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]); } T query(int a, int b) { T vl = t, vr = t; for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) { if (l & 1) vl = f(vl, dat[l++]); if (r & 1) vr = f(dat[--r], vr); } return f(vl, vr); } }; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int n; cin >> n; vector a(n + 1, 1); for (int i = 0; i < n; i++) cin >> a[i]; SegmentTree seg(gcd, 0); seg.build(a); ll ans = 0; int r = 1; for (int l = 0; l < n; l++) { while (r <= n && seg.query(l, r) != 1) r++; ans += n - r + 1; } cout << ans << "\n"; return 0; }