//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 100010001; const ll LINF = (ll)INF*INF*10; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} template struct SegTree { using FX = function; int n; FX fx; const T ex; vector dat; SegTree(int n_, FX fx_, T ex_):fx(fx_), ex(ex_), n(1) { while(n < n_) n <<= 1; dat.assign((n<<1)-1, ex); } inline int chld(int k) {return (k<<1)+1;} inline int chrd(int k) {return (k<<1)+2;} void update(int i, T x) { i += n-1; dat[i] = x; while(i) { i = (i-1)>>1; dat[i] = fx(dat[chld(i)], dat[chrd(i)]); } } inline T query(int a, int b) {return query(a, b, 0, 0, n);} T query(int a, int b, int k, int l, int r) { if(r <= a || b <= l) return ex; if(a <= l && r <= b) return dat[k]; T vl = query(a, b, chld(k), l, (l+r)>>1); T vr = query(a, b, chrd(k), (l+r)>>1, r); return fx(vl, vr); } }; int64_t gcd(int64_t a, int64_t b) {return b?gcd(b, a%b):a;} int64_t lcm(int64_t a, int64_t b) {return a/gcd(a,b)*b;} int64_t extgcd(int64_t a, int64_t b, int64_t &x, int64_t &y) { // ax+by=gcd(a, b)の解を与える int64_t d = a; if(b) { d = extgcd(b, a%b, y, x); y -= (a/b)*x; } else { x = 1; y = 0; } return d; } const int X = 1e6; //head int n; ll ans; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; SegTree seg(n, [](ll i, ll j)->ll{return gcd(i, j);}, 0); rep(i, n) { ll a; cin >> a; seg.update(i, a); } int j = 0; rep(i, n) { bool out = false; while(true) { ll hg = seg.query(i, j+1); if(hg == 1) break; if(j == n-1) { out = true; break; } j++; } if(out) break; ans += n-j; } cout << ans << endl; }