#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(ll i = 0; i < (n); i++)
using ll = long long;
using namespace std;

int main(){
    ll n, ans = 0;
    cin >> n;
    vector<ll>a(n);
    rep(i,n) cin >> a[i];
    ans = (n-1)*(1+n-1)/2;
    sort(a.begin(),a.end());
    bool check = false;
    ll onaji_num = 0;
    ll onaji_sum;
    rep(i,n){
        if(a[i] == a[i+1] && !check){
            check = true;
            onaji_num = 1;
            onaji_sum = 1;
        }else if(a[i] == a[i+1] && check){
            onaji_num++; 
            onaji_sum = (onaji_num)*(1+onaji_num)/2; 
        }else if(a[i] != a[i+1] && check){
            ans -= onaji_sum;
            onaji_num = 0;
            check = false;
        }else{
            if(check){
                ans -= 1;
                onaji_num = 0;
                check = false;
            } 
            continue;
        }
    }
    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    long long n;
    cin>>n;
    long long a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long long sum=0;
    map<int,int>m;
    for(int i=0;i<n;i++)
    {
        sum+=(n-i-1-m[a[i]]);
        m[a[i]]++;
    }
    cout<<sum;
    
    return 0;
}
