#include <bits/stdc++.h>
using namespace std;

int n, a [1000006], div1 [3000006], div2 [3000006];

int main (){

    ios::sync_with_stdio (false);
    cin.tie (0);

    cin >> n;
    for (int i = 0; i < n; i ++) cin >> a [i];
    sort (a, a + n);

    long long ans = 0;
    for (int i = 0; i < n; i ++){
        int x = a [i];
        ans += div2 [x];
        for (int j = x + x; j <= 3000000; j += x){
            div1 [j] ++;
            div2 [j] += div1 [x];
        }
    }
    cout << ans << '\n';

}
