#include #include #include #include #include using namespace std; #define rep(i,n,m) for(int (i)=(n);(i)<(m);(i)++) #define rrep(i,n,m) for(int (i)=(n);(i)>(m);(i)--) using ll = long long; const ll mod = 998244353; template< typename T > struct SparseTable { vector< vector< T > > st; vector< ll > lookup; SparseTable(const vector< T > &v) { ll b = 0; while((1 << b) <= v.size()) ++b; st.assign(b, vector< T >(1 << b)); for(ll i = 0; i < v.size(); i++) { st[0][i] = v[i]; } for(ll i = 1; i < b; i++) { for(ll j = 0; j + (1 << i) <= (1 << b); j++) { st[i][j] = std::gcd(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]); } } lookup.resize(v.size() + 1); for(ll i = 2; i < (ll)lookup.size(); i++) { lookup[i] = lookup[i >> 1] + 1; } } inline T rmq(ll l, ll r) { ll b = lookup[r - l]; return std::gcd(st[b][l], st[b][r - (1 << b)]); } }; int main(){ int N; cin >> N; vector A(N); rep(i,0,N) cin >> A[i]; SparseTable spt(A); ll l = 0 , ans = N*(N-1)/2 + N; rep(r,0,N){ if (A[r] == 1) continue; while (spt.rmq(l,r+1) == 1) l++; ans -= (r-l+1); //cout << l << " " << r << " " << spt.rmq(l,r+1) << endl; } cout << ans << endl; }