#include using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(),A.end() #define RALL(A) A.rbegin(),A.rend() typedef long long LL; typedef pair P; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template T gcd(T a,T b){return b?gcd(b,a%b):a;} const LL mod=1000000007; const LL LINF=1LL<<62; const int INF=1<<30; int dx[]={1,0,-1,0,1,-1,1,-1}; int dy[]={0,1,0,-1,1,-1,-1,1}; template< typename T > struct SparseTable { vector< vector< T > > st; SparseTable() {} SparseTable(const vector< T > &v) { int b = 0; while((1 << b) <= v.size()) ++b; st.assign(b, vector< T >(1 << b)); for(int i = 0; i < v.size(); i++) { st[0][i] = v[i]; } for(int i = 1; i < b; i++) { for(int j = 0; j + (1 << i) <= (1 << b); j++) { st[i][j] = gcd(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]); } } } inline T rmq(int l, int r) // [l, r) { int b = 32 - __builtin_clz(r - l) - 1; return (gcd(st[b][l], st[b][r - (1 << b)])); } }; int main(){ int n;cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } SparseTable st(a); LL ans = 0; for (int i = 0; i < n; i++) { int l = i, r = n + 1; while(abs(r - l) > 1) { int m = (r + l) / 2; if(st.rmq(i, m) != 1) l = m; else r = m; } ans += max(0, n - l); } cout << ans << endl; return 0; }