#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define N (int)(2e5+10)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define nd second
#define st first
#define inf mod
#define endl '\n'
#define sag (sol|1)
#define sol (root<<1)
#define ort ((bas+son)>>1)
#define bit(x,y) ((x>>y)&1)
#define int long long
ll A[N],St[4*N];
int i,j,k,n,m,x,y,z;
int L[4*N],mn[4*N],a[N],L1[N],L2[N];
int R1[N],R2[N],mx[4*N];
void upd(int root,int bas,int son,int x,int y,int t){
if(bas > y or son < x or mn[root] >= t)
return;
if(x <= bas and son <= y and mx[root] <= t){
St[root] = (ll)t*(son-bas+1);
mx[root] = mn[root] = L[root] = t;
return;
}
if(L[root]){
mx[sol] = mx[sag] = mn[sol] = mn[sag] = L[sol] = L[sag] = L[root];
St[sol] = (ll)L[root]*(ort-bas+1);
St[sag] = (ll)L[root]*(son-ort);
L[root] = 0;
}
upd(sol,bas,ort,x,y,t);
upd(sag,ort+1,son,x,y,t);
mn[root] = min(mn[sol] , mn[sag]);
mx[root] = max(mx[sol] , mx[sag]);
St[root] = St[sol] + St[sag];
}
main(){
cin >> n;
for(i=1 ; i<=n ; i++){
scanf("%lld",a+i);
int x = sqrt(a[i]);
for(j=1 ; j<=x ; j++)
if(a[i]%j == 0){
if(!L1[j])
L1[j] = i;
else if(!L2[j]){
L2[j] = i;
}
R2[j] = R1[j];
R1[j] = i;
if(j*j!=a[i]){
if(!L1[a[i]/j])
L1[a[i]/j] = i;
else if(!L2[a[i]/j]){
L2[a[i]/j] = i;
}
R2[a[i]/j] = R1[a[i]/j];
R1[a[i]/j] = i;
}
}
}
for(i=1 ; i<=n ; i++)
upd(1,1,n,i,i,i);
for(i=2e5+1 ; i>=1 ; i--){
if(L1[i] != R1[i]){
upd(1,1,n,1,L1[i],R2[i]);
upd(1,1,n,L1[i]+1,L2[i],R1[i]);
upd(1,1,n,L2[i]+1,n,n+1);
}
A[i] = (ll)n*(n+1) - St[1];
}
ll ans =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SBtbltzYWddID0gTFtzb2xdID0gTFtzYWddID0gTFtyb290XTsKICAgICAgU3Rbc29sXSA9IChsbClMW3Jvb3RdKihvcnQtYmFzKzEpOwogICAgICBTdFtzYWddID0gKGxsKUxbcm9vdF0qKHNvbi1vcnQpOwogICAgICBMW3Jvb3RdID0gMDsKICAgfQoKICAgdXBkKHNvbCxiYXMsb3J0LHgseSx0KTsKICAgdXBkKHNhZyxvcnQrMSxzb24seCx5LHQpOwoKICAgbW5bcm9vdF0gPSBtaW4obW5bc29sXSAsIG1uW3NhZ10pOwogICBteFtyb290XSA9IG1heChteFtzb2xdICwgbXhbc2FnXSk7CiAgIFN0W3Jvb3RdID0gU3Rbc29sXSArIFN0W3NhZ107Cn0KCm1haW4oKXsKICAgY2luID4+IG47CgogICBmb3IoaT0xIDsgaTw9biA7IGkrKyl7CiAgICAgIHNjYW5mKCIlbGxkIixhK2kpOwoKICAgICAgaW50IHggPSBzcXJ0KGFbaV0pOwoKICAgICAgZm9yKGo9MSA7IGo8PXggOyBqKyspCiAgICAgICAgIGlmKGFbaV0laiA9PSAwKXsKICAgICAgICAgICAgaWYoIUwxW2pdKQogICAgICAgICAgICAgICBMMVtqXSA9IGk7CiAgICAgICAgICAgIGVsc2UgaWYoIUwyW2pdKXsKICAgICAgICAgICAgICAgTDJbal0gPSBpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIFIyW2pdID0gUjFbal07CiAgICAgICAgICAgIFIxW2pdID0gaTsKCiAgICAgICAgICAgIGlmKGoqaiE9YVtpXSl7CgogICAgICAgICAgICAgICBpZighTDFbYVtpXS9qXSkKICAgICAgICAgICAgICAgICAgTDFbYVtpXS9qXSA9IGk7CiAgICAgICAgICAgICAgIGVsc2UgaWYoIUwyW2FbaV0val0pewogICAgICAgICAgICAgICAgICBMMlthW2ldL2pdID0gaTsKICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICBSMlthW2ldL2pdID0gUjFbYVtpXS9qXTsKICAgICAgICAgICAgICAgUjFbYVtpXS9qXSA9IGk7CiAgICAgICAgICAgIH0KICAgICAgICAgfQogICB9CgogICBmb3IoaT0xIDsgaTw9biA7IGkrKykKICAgICAgdXBkKDEsMSxuLGksaSxpKTsKCiAgIGZvcihpPTJlNSsxIDsgaT49MSA7IGktLSl7CiAgICAgIGlmKEwxW2ldICE9IFIxW2ldKXsKICAgICAgICAgdXBkKDEsMSxuLDEsTDFbaV0sUjJbaV0pOwogICAgICAgICB1cGQoMSwxLG4sTDFbaV0rMSxMMltpXSxSMVtpXSk7CiAgICAgICAgIHVwZCgxLDEsbixMMltpXSsxLG4sbisxKTsKICAgICAgfQogICAgICBBW2ldID0gKGxsKW4qKG4rMSkgLSBTdFsxXTsKICAgfQoKICAgbGwgYW5zID0gMDsKCiAgIGZvcihpPTEgOyBpPD0yZTUgOyBpKyspCiAgICAgIGFucyArPSAoQVtpKzFdLUFbaV0pKmk7CgogICBjb3V0IDw8IGFucyA8PCBlbmRsOwp9