#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
#include<string>
#include<deque>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll mod = 1000000007;
ll mod2 = 998244353;

ll a[300005];

int main() {
	ll n;
	cin >> n;
	map<ll, ll>mp;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mp[a[i]]++;
	}

	ll ans = 0;
	

	for (int i = 0; i < n; i++) {
		mp[a[i]]--;
		ll cnt = n;
		cnt -= (i + 1);
		ans += (cnt - mp[a[i]]);
	}

	cout << ans << endl;

	return 0;
}
#include <bits/stdc++.h>
#define int long long
#define pb push_back

#define vi vector<int>


#define all(a) a.begin(), a.end()
using namespace std;

void solve()
{
    int n; cin>>n;
    vi a(n);
    int ans=(n*(n-1))/2;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(all(a));
    int cnt=1,val;
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            cnt++;
        }
        else{
            val=(cnt*(cnt-1))/2;
            ans=ans-val;
            cnt=1;
        }
    }
    if(cnt){
        val=(cnt*(cnt-1))/2;
        ans=ans-val;
    }
    cout<<ans;
}

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}
