#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define pb push_back
int a[300005];
signed main()
{
   int n;
   cin>>n;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   sort(a,a+n);
   int cur=0;
   int ans=0;
   for(int i=0;i<n;i++)
   {
       if(!i||a[i]==a[i-1])
       {
           cur++;
       }
       else
       {
           ans+=cur*(n-cur);
           cur=1;
       }
   }
   ans+=cur*(n-cur);
   ans/=2;
   cout<<ans<<endl;
    return 0;
}

/**
 *    author: Ayush
 *    From: Earth
**/
#include <bits/stdc++.h>

using namespace std;
#define ll long long int
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl


int main() {

   ios::sync_with_stdio(false);
   cin.tie(0);

   ll n;
   cin >> n;
   ll ans = 0;
   ll a[n];
   for (ll i = 0 ; i < n ; ++i) {
      cin >> a[i];
   }

   map <ll, ll> mp;
   for (ll i = 0 ; i < n ; ++i) {
      ans += (i) - (mp[a[i]]);
      mp[a[i]]++;
   }

   cout << ans;
   return 0;
}