#include<cstdio>
#include<algorithm>
#define N 300011
using namespace std;
int a[N];
bool cmp(int x,int y)
{
	return x<y;
}
int main()
{
	long long n;
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	long long ans=0,count=0;
	a[0]=-1e9;
	for (int i=1;i<=n;i++)
	{
		if (a[i]!=a[i-1])
		{
			ans=(ans+count*(count-1)/2);
			count=0;
		}
		count++;
	}
	ans=(ans+count*(count-1)/2);
	printf("%lld\n",n*(n-1)/2-ans);
}
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define bits(x,i) (((x) >> (i)) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 3e5 + 5;
int n;
map<int,int> cnt;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	long long ans = 0;
	up(i,1,n){
		int x; cin >> x;
		cnt[x]++;
		ans += i - cnt[x];
	}
	cout << ans;
}