#include<bits/stdc++.h>
using namespace std;
int main(){
    map<int,int> mp;
    int n;
    cin>>n;
    long long ans=0;
    for(int i=0;i<n;++i){
        int x;
        cin>>x;
        int len=i-mp[x];
        ans+=len;
        mp[x]++;
    }
    cout<<ans;
}
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  sort(a.begin(), a.end());

  long long sum = 0;
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] == a[i + 1]) {
      cnt++;
    } else {
      sum += 1LL * cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  sum += 1LL * cnt * (cnt - 1) / 2;

  cout << 1LL * n * (n - 1) / 2 - sum << '\n';
  return 0;
}
