#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
queue<pair<int,int> >Q;
VI ans;
map<int, int> m;
int a[300010];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i ++ ) {
        cin >> a[i];
        m[a[i]] ++;
    }
    sort(a + 1, a + n + 1);
    //for (int i = 1; i <= n; i ++ ) cout << a[i] << " ";
    for (int i = 1; i <= n; i ++ ){
        if (ans.size() && ans.back() == a[i]);
        else ans.push_back(a[i]);
    }
    long long sum = n * 1LL * (n - 1) / 2 ;
    for(auto x : ans){
        sum -= m[x] * 1LL * (m[x] - 1) / 2;
    }
    cout << sum;
    return 0;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountint(x)
#define zrobits(x)      __builtin_ctzint(x)
#define mod             1000000007
#define INF             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define LCM(a,b)		((a*b)/__gcd(a,b))
#define PI              2*acos(0.0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


// If want to add duplicate values replace int with pair below
// and give the second pair value always unique in order to add duplicates in set.

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// W,N,E,S
int dx[] = { -1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

// seive prime
void seive_prime(int N)
{
	vector<bool>prime(N + 1, true);
	vector<int>prime_no;

	prime[0] = false;
	prime[1] = false;

	for (int i = 4; i <= N; i += 2)
	{
		prime[i] = false;
	}

	for (int i = 3; i * i <= N; i += 2)
	{
		if (prime[i])
		{
			int m = i * i;

			while (m <= N)
			{
				prime[m] = false;
				m += i;
			}
		}
	}

	int i = 0;
	for (auto v : prime)
	{
		if (v)
			prime_no.push_back(i);

		i++;
	}

	// return prime_no;
}

// Primality Test
bool isPrime(int n)
{
	if (n == 2)
		return true;

	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
			return false;
	}

	return true;
}

// Modular Exponentiation
int modularExpo(int a, int b, int modVal)
{
	int res = 1;
	while (b > 0)
	{
		if (b & 1)
		{
			res = (res * a) % modVal;
		}

		b = b >> 1;
		a = (a * a) % modVal;
	}
	return (res % modVal);
}


// Euler Totient function
void find_phi(vector<int>&phi)
{
	for (int i = 1; i < phi.size(); i++)
		phi[i] = i;

	for (int i = 2; i < phi.size(); i++)
	{
		if (phi[i] == i)
		{
			for (int j = i; j < phi.size(); j += i)
			{
				phi[j] = phi[j] - (phi[j] / i);
			}
		}
	}

	// for(int i=3; i<phi.size(); i++)
	// {
	// 	phi[i]+=phi[i-1];
	// }
}



int32_t main()
{
	c_p_c();

	// int case_no = 1;

	// w(t)
	// {

	// }

	int n;
	cin >> n;

	int arr[n];

	unordered_map<int, queue<int> >umap;

	for (int i = 0; i < n; i++)
	{
		int no;
		cin >> no;
		umap[no].push(i);
		arr[i] = no;
	}


	int ans = 0;

	for (int i = 0; i < n; i++)
	{
		int val = arr[i];
		int size = umap[val].size();
		size -= 1;

		int remArr = (n - i - 1);
		ans += (remArr - size);

		umap[val].pop();
	}


	cout << ans;












#ifndef ONLINE_JUDGE
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#endif


	return 0;

}