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

void solve(){
   int n;cin>>n;
   map<int,int> cnt;
   set<int> s;
   for(int i=0;i<n;i++){
      int x;cin>>x;
      s.insert(x);cnt[x]++;
   }
   int ans=0;
   for(int x:s)   ans+=(n-cnt[x])*cnt[x];
   cout<<ans/2<<"\n";
}

signed main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   clock_t t1=clock();
   int t;
   //cin>>t;
   t=1;
   while(t--){
      solve();
   }
   cerr<<"Time elapsed: "<<(double)(clock()-t1)/1000<<" s"<<endl;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
//#define float double
#define IOS  std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int v=1000000007;
//fflush(stdout) write after cout or printf 
// * understand question thoroughly (constraints, neg numbers or only positive numbers )...
//....get clarity on input and output types
// *  get idea to solve inclusive of all corner cases and all conditions
//* check for time and space complexity 
//* implement it correctly 

 double sqroot(double n){
   double l=0,r=1000;
   double mid;
   while(r-l>=1e-10){
      mid=l+(r-l)/2;
     if(mid*mid<n)
       l=mid;
      else if(mid*mid>n)
       r=mid;
       else if(abs(mid*mid-n)<=1e-10){
         break; }}
   return mid;}
vector<int> fact(200005,1);
int fac(int n){
  if(n==0 or n==1)
  return fact[n]=1;
return fact[n]=(n%v*(fac(n-1))%v)%v;
  }
int bin(int n,int k){
  int ans=1;int a=n;
  while(k!=0){
  if(k&1){
    ans=ans*a;
    ans=ans%v;}
  a=((a%v)*(a%v))%v;k=k/2;}
  return ans%v;}
int com(int n,int r){
  if(fact[n]==1){
  int ans=((fac(n)%v)*(bin(fact[n-r],v-2)%v))%v;
  ans=ans*(bin(fact[r],v-2)%v);
  return ans%v;}
  else if(fact[n]!=1){
    int ans=((fact[n]%v) * (bin(fact[n-r],v-2)%v))%v;
  ans=ans*(bin(fact[r],v-2)%v);
  return ans%v;}}


bool valid(int i,int x,int y){
  if(i>=x and i<=y){
    return true;
  }
  return false;
}
vector<int>prime;
bool isprime[100005];

void seive_of_erasthones(){
for(int i=2;i<100005;i++){
  isprime[i]=true;}
for(int i=2;i<100005;i++){
  if(isprime[i]){
    prime.push_back(i);
    for(int j=i*i;j<100005;j+=i)
    isprime[j]=false;
  }
}


}


int32_t main()
{ IOS;

int t=1;
//cin>>t;

 
while(t--!=0){
 int n;
 cin>>n;
int a[n];
unordered_map<int,int>mp;
for(int i=0;i<n;i++){
cin>>a[i];
mp[a[i]]++;}
int ans=0;
ans+=(n*(n-1))/2;
for(auto x:mp){
  if(x.second>=2){
    ans-=(x.second*(x.second-1))/2;
  }
}
cout<<ans<<endl;


}


 return 0;}
 
 
 