#include <bits/stdc++.h>
using namespace std;
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)
#define type(x) __typeof(x.begin())
#define orta (bas + son >> 1)
#define sag (k + k + 1)
#define sol (k + k)
#define pb push_back
#define mp make_pair
#define nd second
#define st first
#define endl '\n'
typedef pair < int ,int > pii;
typedef long long ll;
const long long linf = 1e18+5;
int mod = (int) 1e9 + 7;
const int logN = 18;
const int inf = 1e9;
const int N = 2e5 + 5;
int n, m, x, y, z, a[N];
vector< int > H[N], v[N];
ll sum = 0, ans[N];
set< pair< pii , int > > S;
void divide(int x) {
set< pair< pii , int > > :: iterator it, it2;
it = S.lower_bound(mp(mp(x + 1, 0), -1));
if(it == S.begin()) return ; it--;
if(it->st.nd < x) return ;
pair< pii , int > t = *it; S.erase(*it);
S.insert(mp(mp(t.st.st, x), t.nd));
if(x + 1 <= t.st.nd) S.insert(mp(mp(x + 1, t.st.nd), t.nd));
}
void remove(int x) {
divide(x - 1);
while(S.rbegin()->st.st >= x) {
pair< pii , int > t = *S.rbegin();
sum -= (t.st.nd - t.st.st + 1) * (ll) (t.nd);
S.erase(S.find(t));
}
}
void maximize(set< pair< pii , int > > :: iterator it, int x, int y) {
pair< pii , int > t; t.nd = x; t.st.st = y;
set< pair< pii , int > > :: iterator it2;
while(it != S.end()) {
if(it->nd >= x) break;
t.st.nd = it->st.nd;
sum -= (it->st.nd - it->st.st + 1) * (ll) (it->nd);
it2 = it; it2++; S.erase(it); it = it2;
}
if(t.st.st <= t.st.nd) {
sum += (t.st.nd - t.st.st + 1) * (ll) t.nd;
S.insert(t);
}
}
int main() {
scanf("%d", &n);
FOR(i, 1, n) {
scanf("%d", &a[i]);
H[a[i]].pb(i); sum += i;
S.insert(mp(mp(i, i), i));
}
FOR(i, 1, N - 1)
for(int j = i; j < N; j += i)
foreach(it, H[j])
v[i].pb(*it);
ans[N - 1] = n * (ll) (n + 1) / 2;
ROF(i, N - 2, 1) {
int l = v[i].size() - 1;
if(l <= 0) { ans[i] = ans[i + 1]; continue; }
sort(v[i].begin(), v[i].end()); remove(v[i][1] + 1);
maximize(S.begin(), v[i][l-1], 1);
divide(v[i][0]); maximize(S.lower_bound(mp(mp(v[i][0] + 1, v[i][0]), 0)), v[i][l], v[i][0] + 1);
ans[i] = (S.rbegin()->st.nd * (ll)(n + 1) - sum);
}
ll all = 0;
FOR(i, 1, N - 2) all += (ans[i + 1] - ans[i]) * (ll) i;
printf("%lld\n", all);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBkYmdzKHgpIGNlcnIgPDwgKCN4KSA8PCAiIC0tPiAiIDw8ICh4KSA8PCAnICcKI2RlZmluZSBkYmcoeCkgY2VyciA8PCAoI3gpIDw8ICIgLS0+ICIgPDwgKHgpIDw8IGVuZGwKCiNkZWZpbmUgZm9yZWFjaChpLHgpIGZvcih0eXBlKHgpaT14LmJlZ2luKCk7aSE9eC5lbmQoKTtpKyspCiNkZWZpbmUgRk9SKGlpLGFhLGJiKSBmb3IoaW50IGlpPWFhO2lpPD1iYjtpaSsrKQojZGVmaW5lIFJPRihpaSxhYSxiYikgZm9yKGludCBpaT1hYTtpaT49YmI7aWktLSkKCiNkZWZpbmUgdHlwZSh4KSBfX3R5cGVvZih4LmJlZ2luKCkpCgojZGVmaW5lIG9ydGEgKGJhcyArIHNvbiA+PiAxKQojZGVmaW5lIHNhZyAoayArIGsgKyAxKQojZGVmaW5lIHNvbCAoayArIGspCgojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIG1wIG1ha2VfcGFpcgoKI2RlZmluZSBuZCBzZWNvbmQKI2RlZmluZSBzdCBmaXJzdAoKI2RlZmluZS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pbnQgbCA9IHZbaV0uc2l6ZSgpIC0gMTsKICAgICAgICBpZihsIDw9IDApIHsgYW5zW2ldID0gYW5zW2kgKyAxXTsgIGNvbnRpbnVlOyB9CiAgICAgICAgc29ydCh2W2ldLmJlZ2luKCksIHZbaV0uZW5kKCkpOyByZW1vdmUodltpXVsxXSArIDEpOwogICAgICAgIG1heGltaXplKFMuYmVnaW4oKSwgdltpXVtsLTFdLCAxKTsKICAgICAgICBkaXZpZGUodltpXVswXSk7IG1heGltaXplKFMubG93ZXJfYm91bmQobXAobXAodltpXVswXSArIDEsIHZbaV1bMF0pLCAwKSksIHZbaV1bbF0sIHZbaV1bMF0gKyAxKTsKICAgICAgICBhbnNbaV0gPSAoUy5yYmVnaW4oKS0+c3QubmQgKiAobGwpKG4gKyAxKSAtIHN1bSk7CiAgICB9CgogICAgbGwgYWxsID0gMDsKCiAgICBGT1IoaSwgMSwgTiAtIDIpIGFsbCArPSAoYW5zW2kgKyAxXSAtIGFuc1tpXSkgKiAobGwpIGk7CgogICAgcHJpbnRmKCIlbGxkXG4iLCBhbGwpOwoKICAgIHJldHVybiAwOwp9Cg==