#include <bits/stdc++.h>
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define ninpo ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(cntainer) (int)cntainer.size()
#define tc int t;cin>>t;for(int i=0;i<t;++i)
#define ll long long
#define pii pair<int,int>
using namespace std;

/**/
void solve()
{
    ll n;
    cin>>n;
    map<int,ll> ct;
    for (int i = 0; i < n; i++){
        int a;
        cin>>a;
        ct[a]++;
    }
    ll ans= (n*(n-1))/2;
    for(auto i: ct)ans-=((i.second*(i.second-1))/2);
    cout<<ans;
}

int main()
{
       #ifndef ONLINE_JUDGE
           freopen("input.txt", "r", stdin);
           freopen("output.txt", "w", stdout);
       #endif
   ninpo;
//    tc
    solve();
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626
#define mod 1000000007
#define mod1 998244353
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define fo1(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
#define mk(arr,n,type)  type *arr=new type[n];

/*-------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll m) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b = b >> 1;} return res;}
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
ll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
ll mod_div(ll a, ll b, ll m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;}  //only for prime m
/*--------------------------------------------------------------------------------------------*/

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll n;
	cin >> n;
	mk(arr, n, ll);
	map<ll, ll> m;
	for (ll i = 0; i < n; i++) {
		cin >> arr[i];
		m[arr[i]]++;
	}

	ll cnt = 0;
	ll total = n;
	for (auto i : m) {
		ll x = i.ss;
		ll temp = (total - x);
		cnt += (temp * x);
		total -= x;
	}

	cout << cnt << endl;

	return 0;
}