#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1000000007;
const long long small = 100;
vector<long long> fac, finv, inv;



void COMinit(int max) {
	vector<long long> f(max+1);
	vector<long long> finv(max+1);
	vector<long long> inv(max+1);
	f[0] = 1;
	finv[0] = 1;
	inv[0] = 1;
	for (int i = 1; i <= max; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<long> BINARY;
int biFind(long Key,int mode) {
	//need sort beforehand
	//mode 0:first > 1:first >=
	//return -1 if the last is <= or <

	if (mode == 0) {
		if (Key >= BINARY[BINARY.size() - 1]) {
			return -1;
		}
		int l, r, m;
		l = 0;
		r = BINARY.size();
		while (l < r) {
			m = (l + r) / 2;
			if (Key >= BINARY[m]) {
				l = m + 1;
			}
			else {
				r = m;
			}
		}
		return l;
	}
	else {
		if (Key > BINARY[BINARY.size() - 1]) {
			return -1;
		}
		int l, r, m;
		l = 0;
		r = BINARY.size();
		while (l < r) {
			m = (l + r) / 2;
			if (Key > BINARY[m]) {
				l = m + 1;
			}
			else {
				r = m;
			}
		}
		return l;
	}
}
bool biFind(long Key) {
	int l, r, m;
	l = 0;
	r = BINARY.size();
	while (l < r) {
		m = (l + r) / 2;
		if (Key == BINARY[m]) {
			break;
		}
		if (Key > BINARY[m]) {
			l = m + 1;
		}
		else {
			r = m;
		}
	}
	return Key == BINARY[l];
}


int main() {
	//cout << fixed << setprecision(16);
	long N;
	cin >> N;
	vector<long> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	vector<long> B(1, 1);
	int pos = 0;
	for (int i = 1; i < N; i++) {
		if (A[i] == A[i-1]) {
			B[pos]++;
		}
		else {
			B.push_back(1);
			pos++;
		}
	}
	long R = 0;
	for (int i = 0; i < B.size(); i++) {
		//cout << B[i] << endl;
		R += B[i] * (N - B[i]);
	}
	cout << R/2 << endl;
}
#include<bits/stdc++.h>
using namespace std;
#define     ll long long
#define     endl "\n"
#define     f(i,n) for(ll i=0;i<n;i++)
#define     fa(i,a,n) for(ll i=a;i<n;i++)
#define     M 1000000007
#define     pb push_back
#define     vl vector
#define     sp(x) setprecision(x) 


void code()
{
  ll n;
  cin>>n;
  ll a[n];
  f(i,n)
  cin>>a[i];
  ll c=0;
  unordered_map<int,int> m;
f(i,n)
{
    m[a[i]]++;
}
f(i,n-1)
{
    if(m[a[i]]>1){
 c+=(n-1-i)-(m[a[i]]-1);
 m[a[i]]--;
    }else if(m[a[i]]==1)
    c+=(n-1-i);
}
cout<<c<<endl;
}
int main()
{  
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   ll t;
   t=1;
   //cin>>t;
   while(t--)
   {
     code();
   }
   return 0;
}