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

typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;

void solve()
{
    ll n;
    cin >> n;
    map<ll, ll> mp;
    for (ll i = 0; i < n; ++i)
    {
        ll x;
        cin >> x;
        mp[x]++;
    }
    ll ans = n * (n - 1) / 2;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        ll x = itr->second;
        ans -= x * (x - 1) / 2;
    }
    cout << ans << endl;
}

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

    //   ll t;
    //   cin >> t;
    //   while (t--)
    //   {
    cout << setprecision(15) << fixed;
    solve();
    //   }
    return 0;
}
#include <bits/stdc++.h>
#define ll    long long
#define pb    push_back
#define ld    long double
#define sz    size()
#define lala  for(ll i=0;i<n;i++)
#define pll   pair<ll,ll>
#define ed    "\n"
#define ct    cout
#define m_p   make_pair
#define vi    vector<ll>
#define vc    vector<char>
#define ff    first
#define ss    second

using namespace std;

void bahut_tezz()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}


void jai_bajrangbali()
{
    ll k,n,m,x,y,cnt=0,res=0,mx=1;
    ll sum=0;
    bool ash=false;
    string s;
    cin>>n;
    ll a[n];
    lala
    {
        cin>>a[i];
    }

    sort(a,a+n);

//    x=upper_bound(a,a+n,a[n-2])-a+1-1;
//    ct<<x<<ed;

    for(ll i=0;i<n-1;i++)
    {
        x=upper_bound(a,a+n,a[i])-a;
        cnt=cnt+abs(n-x);
    }

    ct<<cnt<<ed;


}

int main()
{
    bahut_tezz();
    long long t=1;
    //cin>>t;
    while(t--)jai_bajrangbali();

    return 0;
}

