#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <iomanip>
#include <cstdio>
#define ll long long int
#define MOD 1000000007
#define inf 20000000000000
#define eps 0.0000000000001
using namespace std ;
vector<int> divi[1000001] ;
ll Mul[1000001] ;
ll ans[1000001] ;
int arr[100001] ;
int main()
{
ios::sync_with_stdio(false);cin.tie(0) ;cout.tie(0) ;
int n ;
cin>>n ;
for(int i = 2 ; i <= 1000000 ; ++i)
{
ll j = i ;
while(j <= 1000000)
{
divi[j].push_back(i) ;
j += i ;
}
}
for(ll i = 0 ; i < n ; ++i)
{
cin>>arr[i] ;
for(ll u : divi[arr[i]])
{
Mul[u]++ ;
}
Mul[1]++;
}
ll zz = 0 ;
for(ll i = 1000000 ; i >= 2 ; --i)
{
if(Mul[i] < 3)
continue ;
ll j = i * 2 ;
ll rem = 0 ;
while(j <= 1000000)
{
rem += ans[j] ;
j+= i ;
}
ans[i] = (Mul[i] * (Mul[i] - 1) * (Mul[i] -2))/6 - rem ;
zz += ans[i] ;
}
cout<<(Mul[1] * (Mul[1] - 1) * (Mul[1] -2))/6 - zz ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPHVub3JkZXJlZF9tYXA+CiNpbmNsdWRlIDx1bm9yZGVyZWRfc2V0PgojaW5jbHVkZSA8Y2xpbWl0cz4KI2luY2x1ZGUgPGlvbWFuaXA+CiNpbmNsdWRlIDxjc3RkaW8+CiNkZWZpbmUgbGwgICBsb25nIGxvbmcgaW50CiNkZWZpbmUgTU9EIDEwMDAwMDAwMDcKI2RlZmluZSBpbmYgIDIwMDAwMDAwMDAwMDAwCiNkZWZpbmUgZXBzICAwLjAwMDAwMDAwMDAwMDEKdXNpbmcgbmFtZXNwYWNlIHN0ZCA7IAp2ZWN0b3I8aW50PiBkaXZpWzEwMDAwMDFdIDsgIAoKbGwgTXVsWzEwMDAwMDFdIDsgCmxsIGFuc1sxMDAwMDAxXSA7ICAKaW50IGFyclsxMDAwMDFdICA7IAppbnQgbWFpbigpCnsKICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpO2Npbi50aWUoMCkgO2NvdXQudGllKDApIDsKICAgaW50IG4gIDsgIAogICBjaW4+Pm4gOyAgICAgCgoKICAgCiAgIGZvcihpbnQgaSAgPSAyIDsgIGkgPD0gIDEwMDAwMDAgOyArK2kpCiAgIHsKICAgICAgbGwgaiAgPSAgaSA7ICAgCiAgICAgIHdoaWxlKGogPD0gMTAwMDAwMCkKICAgICAgewogICAgICAgICBkaXZpW2pdLnB1c2hfYmFjayhpKSA7ICAKICAgICAgICAgaiArPSAgaSAgOyAgCiAgICAgIH0KICAgfQoKICAgIGZvcihsbCAgaSA9ICAwIDsgIGkgPCBuICA7ICsraSkKICAgIHsKICAgICAgICBjaW4+PmFycltpXSA7ICAgCgogICAgICAgIGZvcihsbCB1IDogZGl2aVthcnJbaV1dKQogICAgICAgIHsKICAgICAgICAgICBNdWxbdV0rKyAgOyAKICAgICAgICB9CiAgICAgICAgTXVsWzFdKys7CgogICAgfQogICAgIGxsIHp6ID0gMCAgOyAKICAgIGZvcihsbCBpICA9IDEwMDAwMDAgOyAgaSA+PSAyIDsgIC0taSkKICAgIHsKICAgICAgaWYoTXVsW2ldIDwgMykKICAgICAgICBjb250aW51ZSA7ICAKCiAgICAgIGxsIGogICA9ICBpICogMiAgICA7IAogICAgICBsbCByZW0gPSAwICA7ICAKICAgICAgd2hpbGUoaiA8PSAxMDAwMDAwKQogICAgICB7CiAgICAgICAgIHJlbSArPSBhbnNbal0gOyAgCiAgICAgICAgIGorPSBpIDsgIAogICAgICB9CiAgICAgIGFuc1tpXSAgPSAgKE11bFtpXSAgKiAoTXVsW2ldICAtIDEpICogKE11bFtpXSAgLTIpKS82IC0gcmVtICA7CiAgICAgIHp6ICs9IGFuc1tpXSA7ICAgCiAgICAgIAogICAgfQogICAgY291dDw8KE11bFsxXSAgKiAoTXVsWzFdICAtIDEpICogKE11bFsxXSAgLTIpKS82IC0genogICA7ICAKCgogcmV0dXJuICAwICA7Cn0gCgo=