#include using namespace std; using ll = long long; using pll = pair; #define vc vector using vl = vc; #define ov(a, b, c, name, ...) name #define rep2(i, a, b) for(ll i = (a); i < ll(b); i++) #define rep1(i, n) rep2(i, 0, n) #define rep(...) ov(__VA_ARGS__, rep2, rep1)(__VA_ARGS__) #define fec(...) for(const auto& __VA_ARGS__) #define per(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--) bool chmin(auto& a, auto b) { return a > b ? a = b, 1 : 0; } bool chmax(auto& a, auto b) { return a < b ? a = b, 1 : 0; } const ll INF = ll(4e18) + 100; #define ALL(x) begin(x), end(x) #define SZ(x) (ll) size(x) #define LB(v, x) (lower_bound(ALL(v), x) - begin(v)) #define eb emplace_back void printvec(const auto& v) { for (auto it = begin(v); it != end(v); it++) cout << *it << " "; cout << endl; } #ifdef LOCAL #define local(...) __VA_ARGS__ #else #define local(...) #endif void main2() { ll N; cin >> N; vl A(N); rep(i, N) cin >> A[i]; ll ans = 0; unordered_map dp, ndp; fec(a : A) { ndp = unordered_map(); ndp[a]++; fec([g, cnt] : dp) ndp[gcd(g, a)] += cnt; swap(dp, ndp); ans += dp[1]; local(cout << "a=" << a << endl; fec([g, cnt] : dp) cout << "g=" << g << " cnt=" << cnt << endl); } cout << ans << endl; } int main() { #ifndef LOCAL cin.tie(0)->sync_with_stdio(0), cout.tie(0); #endif local(while(true)) { ll t = 1; // cin >> t; while (t--) main2(); } }