#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define pll pair<ll,ll>
#define ppl pair<pll,ll>
#define plp pair<ll,pll>
#define pi 3.14159265358979323846264338327950
const ll MOD=1e9 + 7;
const ll N=4e5 + 7;
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// use rng for random number generation



ll POWER(ll base,ll expo)
{
    ll ret=1;
    while(expo)
    {
        if(expo&1)ret=ret*base%MOD;
        expo>>=1;
        base=base*base%MOD;
    }
    return ret%MOD;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll tt = 1; //cin>>tt;
    while(tt--)
    {
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        ll n; cin>>n;
        ll ans = n*(n - 1)/2;
        map<ll,ll> mp;
        for(ll i=0;i<n;i++){
            ll x; cin>>x;
            mp[x]++;
        }

        for(auto i : mp){
            ll x = i.se;
            ll rem = x*(x - 1)/2;
            ans -= rem;
        }
        cout<<ans;
    }
    return 0;
}

/*** In the name of Allah(swt), the most gracious, most merciful.***/
/*** Alhamdulillah for Everything ***/


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

typedef bool                   boo;
typedef int                    li;
typedef long                   il;
typedef unsigned long          ul;
typedef long long int          ll;
typedef unsigned long long     ull;
typedef double                 dd;
typedef string                 str;

#define vli                    vector < li >
#define vll                    vector < ll >
#define sli                    set < li >
#define sll                    set < ll >
#define pli                    pair < li , li >
#define pll                    pair < ll , ll >
#define vpi                    vector < pair < li , li > >
#define vpl                    vector < pair < ll , ll > >
#define mpl                    map < ll , ll >

#define Test                   ll t; std :: cin >> t; while(t--)
#define input(a , n)           for( int i = 0 ; i < n ; i++ ) std :: cin >> a[i];
#define lp(a , i , b)          for( ll i = a ; i < b ; i++ )
#define rlp(a , i , b)         for( ll i = a; i >= b ; i-- )
#define sz(x)                  x.size()
#define len(z)                 z.begin() , z.end()
#define ci(x)                  std :: cin >> x;
#define co(x)                  std :: cout << x nl;
#define fix(x)                 fixed << setprecision(x)
#define mem(z , l)             memset( z , l , sizeof(z) )
#define MP                     make_pair
#define pb                     push_back
#define F                      first
#define S                      second
#define nl                     << endl;
#define nll                    std :: cout << endl;
#define cy                     std :: cout << "YES" << endl;
#define cn                     std :: cout << "NO" << endl;
#define rn                     return;
#define Good_Bye               return 0;
#define gcd(a , b)             __gcd( a , b )
#define lcm(a , b)             ( a * ( b / gcd( a , b ) ) )
#define Faster                 ios_base :: sync_with_stdio( 0 ); cin.tie( 0 ); cout.tie( 0 );
int dx[] = { -1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
int dx1[] = { -1, -1, -1, 0, 0, 0, 1, 1, 1};
int dy1[] = { -1, 0, 1, -1, 0, 1, -1, 0, 1};

const double eps =             1e-9;
const int inf =                2000000000;
const ll infLL =               9000000000000000000;
const ll MOD =                 1e+7;
const double PI =              3.141592653589793238462643383279;

///_____________________________________________ L E T ' S  B E G I N ____________________________________________________________

int main()
{
	Faster
	ll x, n, sum(0);
	cin >> n;
	int ar[n + 2]; //,br[n+2];
	map<ll, ll>mp;
	lp(0, i, n)
	{
		cin >> ar[i];
		++mp[ar[i]];
	}
	lp(0, i, n)
	{
		--mp[ar[i]];
		sum += n - i - 1 - mp[ar[i]];
	}
	cout << sum nl
    Good_Bye
}
//                                                                                      author : Md. Nahid Chowdhury(IIUC_CSE48th Batch)
///||||||||||||||||||||||||||||||||||||||||||||||| E N D ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||