// Problem: C - Swappable
// Contest: AtCoder - AtCoder Beginner Contest 206（Sponsored by Panasonic）
// URL: https://atcoder.jp/contests/abc206/tasks/abc206_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define fr(i,n) for(ll i=0;i<n;i++)
#define ff first
#define ss second
#define mp make_pair
#define vl vector<ll>
#define mll map<ll,ll>
#define setbits(x) __builtin_popcountll(x)
#define zrbits(x) __builtin_ctzll(x)
#define vii std::vector<int,int>
#define tc int t;cin>>t;while(t--)
#define FILE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inp(a) long long a;cin>>a;
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll mod=1e9+7;
const ll N=4e5+5;

#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl

void solve(){
	ll n; cin>>n;
	map<ll,ll> m;
	
	fr(i,n){
		ll x; cin>>x;
		m[x]++;
	}
	ll ans=0, temp=n;
	for(auto i:m){
		ll j=i.second;
		temp-=j;
		ans+=j*temp;
	}
	cout<<ans;
}
   
int main(){
	fio;
	ll t=1; //cin>>t;
	while(t--){
		solve();
	}
	printclock;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main() {
    int N;
    scanf("%d",&N);
    map<int,int> M;
    static int A[(int)3e5+16];
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
        M[A[i]]++;
    }
    ll result=0;
    for(int i=0;i<N;i++){
        result+=N-M[A[i]];
    }
    printf("%lld",result/2);
    return 0;
}
