#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; using ll = long long int; ll temp; inline ll gcd(ll a, ll b) { if (a < b) swap(a, b); while (b != 0) { temp = b; b = a % b; a = temp; } return a; } ll a[500010]; template class SegmentTree { public: int N; ll dat[2000010]; constexpr void init(int n) { N = 1; int sz = n; while (N < sz) N *= 2; for (int i = 0; i < N; ++i) dat[i + N - 1] = (i < sz ? a[i] : 0); for (int i = N - 2; i >= 0; --i) dat[i] = gcd(dat[i * 2 + 1], dat[i * 2 + 2]); } constexpr void update(int k, T a) { k += N - 1; dat[k] = a; while (k > 0) { k = (k - 1) / 2; dat[k] = gcd(dat[k * 2 + 1], dat[k * 2 + 2]); } } ll val_left, val_right; constexpr T query(int a, int b) { val_left = 0; val_right = 0; for (a += (N - 1), b += (N - 1); a < b; a >>= 1, b >>= 1) { if ((a & 1) == 0) { val_left = gcd(val_left, dat[a]); } if ((b & 1) == 0) { val_right = gcd(val_right, dat[--b]); } } return gcd(val_left, val_right); } }; int main() { /* cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(30) << setiosflags(ios::fixed); */ ll n; cin >> n; int i; for (i = 0; i < n; i++) scanf("%lld", &a[i]); SegmentTree sg; sg.init(n); ll ans = (n + 1) * n / 2; int lo, hi, mi; for (i = 0; i < n; i++) { lo = i, hi = n + 1; while (hi - lo > 1) { mi = (lo + hi) / 2; if (sg.query(i, mi) > 1) lo = mi; else hi = mi; } ans -= (lo - i); } printf("%lld\n", ans); return 0; }