#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll ans=0,n;
    map<ll,ll>cnt;
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++){
        ll x;
        scanf("%lld",&x);
        cnt[x]++;
        if(i==1)continue;
        ans+=i-cnt[x];
    }
    printf("%lld\n",ans);
    return 0;
}
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define vi vector<ll>
#define mod 1000000007
#define pb push_back
#define vs vector<string>
#define pii pair<ll,ll>
#define unm unordered_map
#define mp make_pair
#define pq_max priority_queue ll;
#define pq_min priority_queue<ll,vi,greater<ll> >
#define all(n) n.begin(),n.end()
#define ff first
#define ss second
#define loop(i,a,b) for(int i=(a);i<=b;i++)
#define loopprev(i,a,b) for(int i=(a);i>=b;i--)
#define bitc(n) __builtin_popcount(n) //the numbers of one in bit representation
#define bitlz(n) __builtin_clz(n) //the number of zeroes at begining of the bit representation
#define bilcz(n) __builtin_ctz(n) //the number of zeroes at the end of the bit representation

template <typename T> T gcd(T a, T b){if(a%b) return gcd(b,a%b);
return b;}

void solve()
{
    ll n;
    cin>>n;
    
    vi a(n);
    loop(i,0,n-1)
    {
        cin>>a[i];
    }
    
    sort(all(a));
    
    ll ans=n*(n-1)/2;
    
    ll c=1;
    loop(i,0,n-1)
    {
        if(a[i]==a[i+1] && i+1<n)
        {
            c++;
        }
        else
        {
            ans=ans-c*(c-1)/2;
            c=1;
        }
    }
    
    cout<<ans<<"\n";
    
}    

int main()
{ 
    solve();
    return 0;
}