func_code_string: #include <bits/stdc++.h>   using namespace std;   using ull = unsigned long long;   using ll = long long;   using ld = long double;   using vi = vector<ll>;   using vvi = vector<vi>;   using vb = vector<bool>;   using ii = pair<ll, ll>;   constexpr bool LOG = false;   void Log() {     if (LOG) cerr <<   n ;   }   template <class T, class... S>   void Log(T t, S... s) {     if (LOG) cerr << t <<   t , Log(s...);   }   ll SIZE;   vector<bool> bs;   vector<ll> primes, mf;   void sieve(ll size = 3e5) {     SIZE = size;     bs.assign(SIZE + 1, 1);     bs[0] = bs[1] = 0;     for (ll i = 2; i <= SIZE; i++)       if (bs[i]) {         for (ll j = i * i; j <= SIZE; j += i) bs[j] = 0;         primes.push_back(i);       }   }   bool is_prime(ll n) {     if (n <= SIZE) return bs[n];     for (const auto &prime : primes)       if (n % prime == 0) return false;     return true;   }   struct Factor {     ll p;     ll exp;   };   using FS = vector<Factor>;   FS factor(ll n) {     FS fs;     for (const auto &p : primes) {       ll exp = 0;       if (n == 1 || p * p > n) break;       while (n % p == 0) n /= p, exp++;       if (exp > 0) fs.push_back({p, exp});     }     if (n != 1) fs.push_back({n, 1});     return fs;   }   vector<ll> divisors(const FS &fs) {     vector<ll> ds{1};     ll s = 1;     for (auto &f : fs) s *= f.exp + 1;     ds.reserve(s);     for (auto f : fs)       for (auto d : ds)         for (ll i = 0; i < f.exp; ++i) ds.push_back(d *= f.p);     return ds;   }   ll n;   using T = ll;   struct FenwickTree {     int n;     vector<T> tree;     FenwickTree(int n) : n(n) { tree.assign(n + 1, 0); }     T query(int l, int r) { return query(r) - query(l - 1); }     T query(int r) {       T s = 0;       for (; r > 0; r -= (r & (-r))) s += tree[r];       return s;     }     void update(int i, T v) {       Log( FT update , i, v);       for (; i <= n; i += (i & (-i))) tree[i] += v;     }   };   struct S {     FenwickTree ft;     map<ll, ll> m;     S(ll n, vi &init) : ft(n) {       Log( init , n);       m[0] = 0;       m[n] = 1e9;       for (ll i = 0; i < n; ++i) update(i, init[i]);       Log( done init );     }     void update(ll i, ll u) {       Log( update , i, u);       auto it = m.lower_bound(i + 1);       auto p = prev(it);       if (u <= p->second) {         Log( return; no increment );         return;       }       Log( shrink , p->first + 1,  remove , (it->first - i) * p->second);       ft.update(p->first + 1, (i - it->first) * p->second);       while (it->second <= u) {         auto nxt = next(it);         if (nxt == m.end()) break;         ft.update(it->first + 1, -(nxt->first - it->first) * it->second);         it = m.erase(it);       }       m[i] = u;       ft.update(i + 1, (it->first - i) * u);       Log( done update );       Log( Map: );     }     ll query(ll i) {       Log( query , i);       auto it = prev(m.lower_bound(i + 1));       ll part = (i - it->first + 1) * it->second;       ll c = ft.query(1, it->first);       Log( query ans: , c, part, c + part);       return c + part;     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     sieve();     cin >> n;     vi v(n);     for (auto &x : v) cin >> x;     vi init(n);     vi count(200001, 0);     vi first(200001, -1);     ll best = 0;     for (ll i = 0; i < n; ++i) {       ll x = v[i];       for (auto div : divisors(factor(x))) {         if (first[div] < 0) first[div] = i;         ++count[div];         if (count[div] >= 2) best = max(best, div);       }       init[i] = best;       Log( init: , i, init[i]);     }     S s(n, init);     ll ans = 0;     ans += s.query(n - 2);     Log(  t t t t t t0..n-2 , ans);     s.update(0, 1);     count.assign(200001, 0);     best = 0;     for (ll i = n - 1; i >= 1; --i) {       Log( suffix from  , i);       ll x = v[i];       for (auto div : divisors(factor(x))) {         ++count[div];         if (count[div] >= 2) {           best = max(best, div);         }         if (first[div] >= 0) s.update(first[div], div);       }       ans += best;       s.update(0, best);       Log(  t t t t t , i,  ..n-1 , best);       if (i - 2 >= 0) {         ll a = s.query(i - 2);         Log(  t t t t tprefix ,  0.. , i - 2, a);         ans += a;       }     }     cout << ans << endl;     return 0;   }   