#include #include using namespace std; using namespace atcoder; using S = long long; S op(S x, S y){ if(x > y) swap(x, y); if(x == 0) return y; return op(y % x, x); } S e(){ return 0; } bool f(S x){ return x != 1; } void solve(){ int n; cin >> n; vector A(n); for(int i = 0; i < n; i++) cin >> A[i]; segtree seg(A); long long ans = 0; for(int r = 1; r <= n; r++){ int l = seg.min_left(r, f); ans += l; } cout << ans << "\n"; } int main(){ cin.tie(0)->sync_with_stdio(0); int t; t = 1; //cin >> t; while(t--) solve(); }