#include <bits/stdc++.h>
using namespace std;
#ifndef LOCAL
#define cerr if(false) cerr
#endif
#define endl "\n"
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
typedef long long ll;
template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { out << x.first << " " << x.second; return out;}
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
const ll MAX_N = 1e6 + 10;
ll arr[MAX_N];
ll n;
bool has[MAX_N];
ll small[MAX_N];
ll big[MAX_N];
signed main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif
    cin >> n;
    for(ll i = 0; i < n; i ++) {
        cin >> arr[i];
        has[arr[i]] = true;
    }
    for(ll i = 0; i < MAX_N; i ++) {
        if(!has[i]) {continue;}
        for(ll j = 2 * i; j < MAX_N; j += i) {
            if(has[j]) {
                small[j] ++;
                big[i] ++;
            }
        }
    }
    ll cnt = 0;
    for(ll i = 0; i < n; i ++) {
        cnt += small[arr[i]] * big[arr[i]];
    }
    cout << cnt << endl;
    return 0;
}