#include <bits/stdc++.h>
#define ll                long long int
#define ld                long double
#define endl              "\n"
#define mp                make_pair
#define HCF               __gcd
#define LCM(m,n)          (m*n)/__gcd(m,n)
#define maxa(v)           *(max_element(all(v))
#define mina(v)           *(min_element(all(v))
#define vi                vector<ll>
#define pll               pair<ll,ll>
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define M                 998244353ll
#define S                 second
#define F                 first
#define inf               (int)1e9
#define fon(i,j,n)        for(ll i=j;i<(n);++i)
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define asort(v)          sort(v.begin(),v.end())
#define dsort(v)          sort(v.begin(),v.end(),greater<int>())
#define BS(v,k)           binary_search(v.begin(),v.end(),k)
#define UB(v,k)           (upper_bound(v.begin(),v.end(),k)-v.begin())
#define LB(v,k)           (lower_bound(v.begin(),v.end(),k)-v.begin())
#define mod               1000000007ll
using namespace std;
bool prime(ll n){bool b=true;
    for(ll i=2;i<=sqrt(n);i++){if(n%i==0){b=false;break;
        }
    }
    if(b)return true;
    else return false;
}


void solve(){
 ll n;cin>>n;
map<ll,ll>m;set<ll>s;
fon(i,0,n){ll x;cin>>x;s.insert(x);m[x]++;}
vi sum;
sum.pb(0);
ll k=1;
for(auto i:s) { sum.pb(sum[k - 1] + m[i]);k++; }
k=sum.size();
ll ans=0;
fon(i,1,k){ans+=(sum[i]-sum[i-1])*(sum[k-1]-sum[i]);}

cout<<ans;
    return;
}

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

    int tsc=1;
    while(tsc--){
        solve();
        cout<<endl;  }

    return 0;
}
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

using vi=vector<int>;
using vvi=vector<vi>;
using LL=long long;
using vL=vector<LL>;
using vvL=vector<vL>;




int main() {
  long long n;
  cin>>n;
  
  
  long long a;
  map<long long ,long long > Map;
  for (int i=0 ; i<n ; i++) {
    cin>>a;
    Map[a]++;
  }
  
  long long ans=n*(n-1)/2;
  for (auto k : Map) {
    long long m=k.second;
    ans-=m*(m-1)/2;
  }
  cout<<ans<<endl;
}