#include #include using namespace atcoder; using namespace std; using ll = long long; ll op(ll a, ll b) {return gcd(a, b);} ll e() {return 0LL;} int main() { int N;cin >> N; vector A(N + 1, 0); for (int i = 1;i <= N;i++) cin >> A[i]; segtree seg(A); ll ans = 0; for (int i = 1;i <= N;i++) { int ok = i; int ng = N +1; if (A[i] == 1) { ans += N - i + 1;continue; } while (ng - ok > 1) { int m = (ok + ng) / 2; ll g = seg.prod(i, m + 1); if (g == 1) { ng = m; } else { ok = m; } } if (ok == i) { ans += N - i; } else { ans += N - ok; } } cout << ans << endl; }