#include using namespace std; #define rep2(i, m, n) for(int i=int(m); i=int(n); --i) #define rep(i, n) rep2(i, 0, n) #define drep(i, n) drep2(i, n, 0) #define all(a) a.begin(), a.end() using ll = long long; using ld = long double; using V = vector; using Vll = vector; using Vld = vector; using Vbo = vector; using VV = vector; using VVll = vector; using VVld = vector; using VVbo = vector; using P = pair; using Pll = pair; using Pld = pair; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template istream &operator>>(istream &is, pair &p) { is >> p.first >> p.second; return is; } template ostream &operator<<(ostream &os, const pair &p) { os << "(" << p.first << ", " << p.second << ")"; return os; } template istream &operator>>(istream &is, vector &v) { for (auto &e : v) is >> e; return is; } template ostream &operator<<(ostream &os, const vector &v) { for (auto &e : v) os << e << " "; return os; } template inline int count_between(vector &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r) inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits const int INF = 1<<30; const ll INFll = 1ll<<62; const ld EPS = 1e-10; const int MOD = int(1e9)+7; template struct SegmentTree { int m, n; // m: size of original vector, n: size of segment tree vector d; T idt = 0; T op(T &a, T &b) { // return a + b; return gcd(a, b); } SegmentTree(vector v) : m(v.size()) { n = 1; while(n < m) n <<= 1; d.assign(2*n-1, 0); rep(i, m) d[i+n-1] = v[i]; drep(i, n-1) d[i] = op(d[i*2+1], d[i*2+2]); } void add(int k, T val) { k += n-1, d[k] += val; while (k) k = (k-1)/2, d[k] = op(d[2*k+1], d[2*k+2]); } void set(int k, T val) { k += n-1, d[k] = val; while (k) k = (k-1)/2, d[k] = op(d[2*k+1], d[2*k+2]); } T op_range(int a, int b, int k=0, int l=0, int r=-1) { if (r < 0) r = n; if (b <= l || r <= a) return idt; if (a <= l && r <= b) return d[k]; T vl = op_range(a, b, 2*k+1, l, (l+r)/2); T vr = op_range(a, b, 2*k+2, (l+r)/2, r); return op(vl, vr); } T get(int a) { return d[n-1+a]; } vector get_all() { vector res(m); copy(d.begin()+n-1, d.begin()+n+m-1, res.begin()); return res; } }; int main() { ll n; cin >> n; Vll a(n); cin >> a; ll ans = 0; SegmentTree st(a); int j = 0; rep(i, n) { ll y = st.op_range(i, j+1); while (j < n && st.op_range(i, j+1) > 1) ++j; ans += n-j; if (i == j) ++j; } cout << ans << endl; return 0; }