#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 SWAG { SWAG(int n) : t(n), s(), i0(0), i1(0), i2(0) {} void push(const T &o) { t[i2++] = o; s = s * o; } void pop() { if (i0 == i1) { i1 = i2; for (int i = i1 - 2; i > i0; i--) { t[i] = t[i] * t[i + 1]; } s = T(); } i0++; } T fold_all() { return i0 == i1 ? s : t[i0] * s; } vector t; T s; int i0, i1, i2; }; struct Node { constexpr Node() : a(0) {} Node(ll a) : a(a) {} Node operator*(const Node &o) const { return Node(gcd(a, o.a)); } ll a; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } SWAG sw(n); ll r = 0; for (int i0 = 0, i1 = 0; i0 < n; i0++) { while (i1 < n && sw.fold_all().a != 1) { sw.push(Node(a[i1++])); } if (i1 == n && sw.fold_all().a != 1) i1++; r += n - i1 + 1; sw.pop(); } cout << r << endl; return 0; }