#include using namespace std; typedef long long ll; #define inf 10e17 #define rep(i,n) for(long long i=0; i()) #define debug(x) std::cerr << (x) << std::endl; #define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; } template inline void chmax(T &ans, T t) { if (t > ans) ans = t;} template inline void chmin(T &ans, T t) { if (t < ans) ans = t;} template class SegTree { int n; // 葉の数 vector data; // データを格納するvector T def; // 初期値かつ単位元 function operation; // 区間クエリで使う処理 function update; // 点更新で使う処理 // 区間[a, b)の総和。ノードk=[l, r)に着目している。 T _query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return def; // 交差しない if (a <= l && r <= b) return data[k]; // a,l,r,bの順で完全に含まれる else { T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 return operation(c1, c2); } } public: /** * コンストラクタ * @param _n 必要サイズ * @param _def 初期値かつ単位元 * @param _operation クエリ関数 * @param _update 更新関数 */ SegTree(size_t _n, T _def, function _operation, function _update) : def(_def), operation(_operation), update(_update) { n = 1; while (n < _n) { n *= 2; } data = vector(2 * n - 1, def); } SegTree(vector& A, T _def, function _operation, function _update) : def(_def), operation(_operation), update(_update) { n = 1; auto _n = A.size(); while (n < _n) { n *= 2; } data.resize(2 * n, _def); for (int i = 0; i < _n; ++i) data[i + n - 1] = A[i]; for (int i = n - 2; i >= 0; --i) data[i] = operation(data[i*2+1], data[i*2+2]); } /** * [a, b)の区間クエリを実行 * @param a 左端 * @param b 右端 * @return クエリの結果 */ T query(int a, int b) { return _query(a, b, 0, 0, n); } /** * 場所i(0-indexed)の値をxで更新 * @param i * @param x */ void change(int i, T x) { i += n - 1; data[i] = update(data[i], x); while (i > 0) { i = (i - 1) / 2; data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]); } } T operator[](int i) { return data[i + n - 1]; } }; // 最大公約数を求める(ユークリッドの互除法). long long gcd (long long x, long long y) { if (y > x) swap(x,y); if (y == 0) return x; return gcd(x%y,y); } signed main() { int n; cin >> n; vector a(n); repr(i, n, 0) { cin >> a[i]; } SegTree segTree(a, 0, [](auto const a, auto const b){ return gcd(a,b); }, [](auto const a, auto const b){ return b; }); ll ans = 0; ll r = 0; for (ll l = 0; l < n; ++l) { if (l > r) r = l; while (r < n and segTree.query(l, r + 1) > 1) { r ++; } ans += n - r; } cout << ans << endl; }