#include <bits/stdc++.h>
using namespace std;
#define trav(a, x) for(auto& a : x)
#define vi vector<int>
#define fo(i, k, n) for(int i = k; i < n; ++i)
typedef long long ll;
void setIO(string name = "") { 
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(name.size()){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

const int mod = 1e9 + 7;

int main()
{	
    setIO();
    int n;
    cin >> n;
    map<int, ll> count;
    ll res = 0;
    for(int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        res += (i - count[k]);
        count[k]++;
    }
    cout << res << endl;
    return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;

    vector<int> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }

    const int MIN_ELEM = *min_element(A.begin(), A.end());
    unordered_map<int, int> memo;
    memo[MIN_ELEM] = MIN_ELEM;
    for(int i = 0; i < N; ++i){
        for(int d = 1; d * d <= A[i]; ++d){
            if(A[i] % d == 0){
                for(int divisor: set<int>{d, A[i] / d}){
                    memo[divisor] = (memo.count(divisor) ? __gcd(memo[divisor], A[i]) : A[i]);
                }
            }
        }
    }

    int answer = 0;
    for(const pair<int, int>& P: memo){
        answer += (P.first == P.second && P.first <= MIN_ELEM);
    }

    cout << answer;

    return 0;
}