#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define M 1000000007
using namespace std;
vector<ll> P;
int c = 0;
int prm[1010101];
ll ans = 0;
vector<ll> tek[1010101];
bool prime(ll x) {
return !prm[x];
}
int z[1010101];
ll cnt[1010101];
vector<ll> dh;
vector<ll> vi[10];
vector<int> vi2[10][222];
void haku2(ll s, ll pr, ll d) {
int sz = tek[pr].size();
int nm = (1<<sz);
assert(nm>1);
int qq[nm];
for(int i=0; i<nm; i++)
qq[i] = 0;
for(auto i:vi[sz]) {
ll lk = 1;
for(ll j=0; j<sz; j++) {
if((i&(1<<j)))
lk *= tek[pr][j];
}
int lol = 0;
for(auto u:vi2[sz][i]) {
lol += qq[u];
}
/* for(int j=i+1; j<nm; j++) {
if((j|i) ==j) {
lol += qq[j];
}
}*/
qq[i] += cnt[lk]-lol;
ans -= qq[i];
cnt[lk]++;
}
}
ll cnttt;
void haku1(ll s, ll pr, ll d) {
ll d2 = d;
queue<int> q;
queue<int> q2;
q2.push(s);
vector<pair<int,int>> dv;
map<int,int> mp;
lol:
d += d2;
d2 = 0;
q = q2;
q2 = {};
while(!q2.empty())
q2.pop();
while(!q.empty()) {
s = q.front();
q.pop();
int qq = 0;
for(auto u:mp) {
if(u.first%s == 0)
qq +=u.second;
}
ll lk = cnt[s]-qq;
ans -= lk;
cout << pr << " " <<s << " " << lk<<endl;
cnt[s]++;
// assert(s>1);
if(lk)
mp[s]+=lk;
for(auto u:tek[pr]) {
if(u < s && s%u == 0) {
if(z[s/u] == c) {
continue;
} else {
z[s/u] = c;
}
q2.push(s/u);
}
}
}
if(!q2.empty()) {
goto lol;
}
}
int cntt = 0;
int mx = 0;
void pr(ll x) {
ll sm = 1;
if(x == 1)
return;
vector<ll> v;
if(prime(x)) {
sm = x;
v.push_back(x);
} else {
while(x > 1) {
ll lk = prm[x];
if(lk == 0) {
if((v.size() == 0 || v[v.size()-1] != x)) {
sm *= x;
v.push_back(x);
}
break;
}
if(v.size() == 0 || v[v.size()-1] != lk) {
sm *= lk;
v.push_back(lk);
}
x /= lk;
}
}
/* for(auto u:v)
cout << u<< " . ";
cout<<endl;*/
tek[sm] = v;
haku2(sm, sm, 0);
//cnt[sm]++;
}
ll brute(vector<ll> v) {
ll ret = 0;
for(int i=0; i<v.size(); i++) {
for(int j=i+1; j<v.size(); j++)
if(__gcd(v[i], v[j]) == 1)
ret++;
}
return ret;
}
int main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio();
for(int i=1; i<8; i++) {
for(int j=i; j>=1; j--) {
for(int g=1; g<(1<<i); g++) {
if(__builtin_popcount(g) == j) {
vi[i].push_back(g);
}
}
}
/* for(int j=i+1; j<nm; j++) {
if((j|i) ==j) {
lol += qq[j];
}
}*/
for(int g=1; g<(1<<i); g++) {
for(int j=g+1; j<(1<<i); j++) {
if((j|g) ==j) {
vi2[i][g].push_back(j);
}
}
}
}
prm[1] = 1;
for(ll i=2; i<=1000000; i++) {
if(!prm[i]) {
P.push_back(i);
for(ll j=2; j*i<=1e6; j++)
if(!prm[i*j])
prm[i*j] = i;
}
}
ll n;
cin >> n;
ans = n*(n-1)/2;
vector<ll> bv;
for(int i=0; i<n; i++) {
int x;
cin >> x;
bv.push_back(x);
c = i+1;
pr(x);
}
cnt[1] = 0;
cout << ans << endl;
//cout << ans << endl;
}