#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; template struct SparseTable{ vector> spt; vector vlog; using F=function; const F f; SparseTable(const F f, const vector &v):f(f){ int b=0, n=v.size(); while((1<(n)); for(int i=0; i>1]+1; } inline T query(int l, int r){ int b=vlog[r-l]; return f(spt[b][l], spt[b][r-(1< a(n); for(int i=0; i seg([&](ll x, ll y){ return gcd(x, y);}, a); ll ans=0; int r=1; for(int i=0; i1){ int mid=(l+r)/2; if(seg.query(i, mid)==1) r=mid; else l=mid; } ans+=n+1-r; } printf("%lld\n", ans); return 0; }