#include <bits/stdc++.h>

const int mod1 = 998244353, mod2 = 1e9 + 7;
const int N = 1e6 + 5, M = 1e7 + 5;

void solve() {
	int n; std::cin >> n;
	std::vector<int> a(n);
	std::map<int, int> mp;
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
		mp[a[i]]++;
	}
	long long ans = 0;
	for (auto &it : mp) {
		ans += 1LL * it.second * (n - it.second);
		n -= it.second;
	}	
	std::cout << ans << '\n';
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
	int T = 1; //std::cin >> T;
	while (T--) {
    solve();
  }
  return 0;
}
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
 
int main() {
    ll n;
    cin >> n;

    map<ll, ll> mp;
    rep(i, n) {
        ll a;
        cin >> a;
        mp[a]++;
    }

    ll ans = 0; 
    for(auto p : mp) {
        ans += p.second * (n - p.second);
    }

    ans /= 2;
    
    out(ans);
    re0;
}