#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include using namespace std; vector segtree(vector &A){ int N = 1; while (N < A.size()){ N = N * 2; } vector ST(N * 2 - 1); for (int i = 0; i < A.size(); i++){ ST[i + N - 1] = A[i]; } for (int i = A.size() + N - 1; i < N * 2 - 1; i++){ ST[i] = 0; } for (int i = N - 2; i >= 0; i--){ ST[i] = __gcd(ST[i * 2 + 1], ST[i * 2 + 2]); } return ST; } long long segtree_query(vector &ST, int x, int y, int i, int L, int R){ if (y <= L || R <= x){ return 0; } else if (x <= L && R <= y){ return ST[i]; } else { int M = (L + R) / 2; long long A = segtree_query(ST, x, y, i * 2 + 1, L, M); long long B = segtree_query(ST, x, y, i * 2 + 2, M, R); return __gcd(A, B); } } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector ST = segtree(A); if (ST[0] != 1){ cout << 0 << endl; } else { int X = (ST.size() + 1) / 2; long long ans = 0; for (int i = 0; i < N; i++){ if (segtree_query(ST, i, N, 0, 0, X) == 1){ int tv = N + 1; int fv = i - 1; while (tv - fv > 1){ int mv = (tv + fv) / 2; if (segtree_query(ST, i, mv + 1, 0, 0, X) == 1){ tv = mv; } else { fv = mv; } } ans += N - tv; } } cout << ans << endl; } }