#include #include #include #include #include #include #include using namespace std; using ll = long long; ll gcd(ll n, ll m) { if (n < m) swap(n, m); while (m != 0) { ll r = n % m; n = m; m = r; } return n; } template struct SegmentTree { SegmentTree(int n) : n(n) { for (m = 2; m < n; m *= 2); t = vector(m + n + n % 2); } T &operator[](int i) { return t[m + i]; } const T &root() const { return t[1]; } void build() { for (int i = (n - 1 + m) / 2; i > 0; i--) t[i] = t[i * 2] * t[i * 2 + 1]; } void update(int i, const T &o) { for (t[i += m] = o; i /= 2, i > 0;) t[i] = t[i * 2] * t[i * 2 + 1]; } T query(int l, int r) { T o0, o1; for (l += m, r += m; l < r; l /= 2, r /= 2) { if (l & 1) o0 = o0 * t[l++]; if (r & 1) o1 = t[--r] * o1; } return o0 * o1; } vector t; int n, m; }; struct Node { constexpr Node() : v(0) {} Node(ll v) : v(v) {} Node operator*(const Node &o) const { return gcd(v, o.v); } ll v; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; SegmentTree st(n); for (int i = 0; i < n; i++) { cin >> st[i].v; } st.build(); ll r = 0; for (int i0 = 0, i1 = 0; i0 < n; i0++) { if (i1 <= n) { Node t = st.query(i0, i1).v; while (t.v != 1) { if (++i1 > n) break; t = t * st[i1 - 1].v; } } r += n - i1 + 1; } cout << r << endl; return 0; }