#include #define rep(i,n) for (int i = 0; i < (n); i ++) using namespace std; typedef long long ll; typedef pair PL; typedef pair P; const ll INF = 1e9; const ll MOD = 1e9 + 7; template class SegmentTree { int N = 1; vector tree; function func; T unit; public: SegmentTree(vector array,function _func,T _unit) :func(_func),unit(_unit) { int n = array.size(); while (N < n) N *= 2; tree = vector(2*N,unit); for (int i = 0;i < n; i++) tree[i + N - 1] = array[i]; for (int i = N - 2; i >= 0; i--) tree[i] = func(tree[2*i + 1],tree[2*i + 2]); } void update(int k,T x) {//k番目の要素をxに変更する k += N - 1; tree[k] = x; while (k) { k = (k - 1)/2; tree[k] = func(tree[2*k + 1],tree[2*k + 2]); } } T query(int l,int r) {//開区間[l,r)のクエリに答える if (r <= l) return unit; l += N - 1; r += N - 2; T ans = unit; while (r - l > 1) { if ((l&1) == 0) ans = func(ans,tree[l]); if ((r&1) == 1) {ans = func(ans,tree[r]); r--;} l /= 2; r = (r - 1)/2; } if (l == r) ans = func(ans,tree[l]); else ans = func(func(ans,tree[l]),tree[r]); return ans; } }; int main() { int n; cin >> n; vector a(n); rep(i,n) cin >> a[i]; SegmentTree st(a,[](ll a, ll b){return __gcd(a,b);},0); int r = 0; ll ans = 0; for (int l = 0;l < n;l ++) { while (r < n && st.query(l,r + 1) != 1) r ++; ans += n - r; } cout << ans << endl; }