#include using namespace std; using ll = long long; template struct SparseTable { using T = typename SemiLattice::T; int n; vector< vector > table; vector log_table; SparseTable() {} SparseTable(const vector& v) : n(v.size()) { log_table.resize(n + 1, 0); for (int i = 2; i <= n; i++) { log_table[i] = log_table[i >> 1] + 1; } table.resize(log_table[n] + 1, vector(n)); for (int i = 0; i < n; i++) { table[0][i] = v[i]; } size_t sz = table.size(); for (int i = 1; i < sz; i++) { for (int j = 0; j + (1 << i) <= n; j++) { table[i][j] = SemiLattice::merge(table[i - 1][j], table[i - 1][j + (1 << (i - 1))]); } } } //区間[l, r)に対するクエリに答える T query(int l, int r) { assert(l < r && r <= n); int k = log_table[r - l]; return SemiLattice::merge(table[k][l], table[k][r - (1 << k)]); } }; //以下、SemiLatticeの例 template struct RMQSL { using T = U; static T merge(T a, T b) { return __gcd(a, b); } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } SparseTable< RMQSL<> > st(a); ll ans = 0; for (int i = 0; i < n; ++i) { int ok = n + 1, ng = i; while (ok - ng > 1) { int mid = (ok + ng) / 2; (st.query(i, mid) == 1 ? ok : ng) = mid; } ans += n + 1 - ok; } cout << ans << "\n"; return 0; }