#include <bits/stdc++.h>
#define rep(i,n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main()
{
  ll n; cin >> n;
  map<ll, ll> map;
  rep(i, n) {
    ll x; cin >> x;
    map[x]++;
  }
  ll ans = n*(n-1)/2;
  for (auto p : map) {
    auto num = p.second;
    ans -= num * (num-1) / 2;
  }
  cout << ans << endl;
}
/*
	You Can Do This!
	From Madeline
	To You
	https://www.youtube.com/watch?v=vBUhgkMD5kc
*/
#include <bits/stdc++.h>

#define inf ll (1e18)
#define ninf ll (-1e18)
#define mod ll (1e9 + 7)
#define first F
#define second S
#define fast ios::sync_with_stdio (0); cin.tie (0);

using namespace std;
using ll = long long;
using pi = pair < ll , ll >;

void solution (ll tc = 0) {
	ll n;
	cin >> n;
	
	map < ll , ll > m;
	vector < ll > v (n);
	
	for (ll i = 0; i < n; i++) {
		cin >> v[i];
		m[v[i]]++;
	}
	
	ll current = n - 1;
	ll res = 0;
	
	for (ll i = 0; i < n; i++) {
		ll x = m[v[i]]--;
		x--;
		
		res += current - x;
		current--;
	}
	
	cout << res << '\n';
}

int main () {
	fast
	
	solution ();
}