#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a[100005],t[100005],t2[100005],uc[100005],kq = 0,s,s2;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
freopen("Basohang.inp", "r", stdin);
freopen("Basohang.out", "w", stdout);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
if(n <= 1000)
{
for(int i = 2; i < n; i++)
{
s = s2 = 0;
for(int j = i - 1; j >= 1; j--)
s += (a[i] % a[j] == 0);
for(int j = i + 1; j <= n; j++)
s2 += (a[j] % a[i] == 0);
kq += s*s2;
}
cout << kq;
return 0;
}
else
{
kq = 0;
for(int i = 2; i <= n; i++)
{
for(int j = 1; j <= sqrt(a[i]); j++)
{
if(a[i] % j == 0)
{
uc[j]++;
if(a[i]/j != j)
uc[a[i]/j]++;
}
}
}
t2[a[1]]++;
for(int i = 2; i < n; i++)
{
for(int j = 1; j <= sqrt(a[i]); j++)
{
if(a[i] % j == 0)
{
uc[j]--;
if(a[i]/j != j)
uc[a[i]/j]--;
}
}
for(int j = 1; j <= sqrt(a[i]); j++)
{
if(a[i] % j == 0)
{
kq += uc[a[i]] * t2[j];
if(a[i]/j != j)
kq += uc[a[i]] * t2[a[i]/j];
}
}
t2[a[i]]++;
}
cout << kq;
return 0;
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKbGwgbixhWzEwMDAwNV0sdFsxMDAwMDVdLHQyWzEwMDAwNV0sdWNbMTAwMDA1XSxrcSA9IDAscyxzMjsKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOyBjaW4udGllKDApOyBjb3V0LnRpZSgwKTsKICAgIGZyZW9wZW4oIkJhc29oYW5nLmlucCIsICJyIiwgc3RkaW4pOwogICAgZnJlb3BlbigiQmFzb2hhbmcub3V0IiwgInciLCBzdGRvdXQpOwogICAgY2luID4+IG47CiAgICBmb3IoaW50IGkgPSAxOyBpIDw9IG47IGkrKykKICAgIGNpbiA+PiBhW2ldOwogICAgaWYobiA8PSAxMDAwKQogICAgewogICAgICAgIGZvcihpbnQgaSA9IDI7IGkgPCBuOyBpKyspCiAgICAgICAgewogICAgICAgICAgICBzID0gczIgPSAwOwogICAgICAgICAgICBmb3IoaW50IGogPSBpIC0gMTsgaiA+PSAxOyBqLS0pCiAgICAgICAgICAgICAgICBzICs9IChhW2ldICUgYVtqXSA9PSAwKTsKICAgICAgICAgICAgZm9yKGludCBqID0gaSArIDE7IGogPD0gbjsgaisrKQogICAgICAgICAgICAgICAgczIgKz0gKGFbal0gJSBhW2ldID09IDApOwogICAgICAgICAgICBrcSArPSBzKnMyOwogICAgICAgIH0KICAgICAgICBjb3V0IDw8IGtxOwogICAgICAgIHJldHVybiAwOwogICAgfQogICAgZWxzZQogICAgewogICAgICAgIGtxID0gMDsKICAgICAgICBmb3IoaW50IGkgPSAyOyBpIDw9IG47IGkrKykKICAgICAgICB7CiAgICAgICAgICAgIGZvcihpbnQgaiA9IDE7IGogPD0gc3FydChhW2ldKTsgaisrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZihhW2ldICUgaiA9PSAwKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHVjW2pdKys7CiAgICAgICAgICAgICAgICAgICAgaWYoYVtpXS9qICE9IGopCiAgICAgICAgICAgICAgICAgICAgICAgIHVjW2FbaV0val0rKzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB0MlthWzFdXSsrOwogICAgICAgIGZvcihpbnQgaSA9IDI7IGkgPCBuOyBpKyspCiAgICAgICAgewogICAgICAgICAgICBmb3IoaW50IGogPSAxOyBqIDw9IHNxcnQoYVtpXSk7IGorKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYoYVtpXSAlIGogPT0gMCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICB1Y1tqXS0tOwogICAgICAgICAgICAgICAgICAgIGlmKGFbaV0vaiAhPSBqKQogICAgICAgICAgICAgICAgICAgICAgICB1Y1thW2ldL2pdLS07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZm9yKGludCBqID0gMTsgaiA8PSBzcXJ0KGFbaV0pOyBqKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmKGFbaV0gJSBqID09IDApCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAga3EgKz0gdWNbYVtpXV0gKiB0MltqXTsKICAgICAgICAgICAgICAgICAgICBpZihhW2ldL2ogIT0gaikKICAgICAgICAgICAgICAgICAgICAgICAga3EgKz0gdWNbYVtpXV0gKiB0MlthW2ldL2pdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIHQyW2FbaV1dKys7CiAgICAgICAgfQogICAgICAgIGNvdXQgPDwga3E7CiAgICAgICAgcmV0dXJuIDA7CiAgICB9Cn0K