#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include "bits/stdc++.h" #pragma warning(disable:4996) using namespace std; #define int long long #define rep(i,n) for(int i=0;inode; int n; void init(int N) { n = 1; while (n < N) { n *= 2; } node.resize(2 * n, 0); } void upd(int a, int x) { a += n - 1; node[a] = x; while (a > 0) { a = (a - 1) / 2; node[a] = gcd(node[2 * a + 1], node[2 * a + 2]); } } int calc(int a, int b, int k, int l, int r) { if (r <= a || b <= l)return 0; if (a <= l&&r <= b)return node[k]; int vl = calc(a, b, k * 2 + 1, l, (l + r) / 2); int vr = calc(a, b, k * 2 + 2, (l + r) / 2, r); return gcd(vl, vr); } int get(int a, int b) { return calc(a, b, 0, 0, n); } }; segtree seg; signed main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; seg.init(n); rep(i, n) { cin >> a[i]; seg.upd(i, a[i]); } int res = 0; rep(i, n) { int l = i - 1, r = n; while (r - l > 1) { int mi = (l + r) / 2; if (seg.get(i, mi + 1) == 1)r = mi; else l = mi; } res += n - r; } cout << res << endl; }