#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);
    set<long long> dup;
    multiset<long long> dupnum;
    for (long long i = 0; i < n; i++) {
        cin >> a[i];
        dup.insert(a[i]);
        dupnum.insert(a[i]);
    }

    long long all = (n*(n-1))/2;
    //cout << all << endl;

    for (auto x : dup){
        long long count = dupnum.count(x);
        //cout << count << endl;
        if (count >= 2){
            long long minus = (count*(count-1))/2;
            all-=minus;
        }
    }

    cout << all << endl;
    
}
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define rep(i,a,b) for(int i=a;i< b;i++)
#define endl "\n"
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define fr first
#define sc second
#define INF (int)(1e18)
#define pb push_back
#define ppb pop_back
#define sz(x) (int)((x).size())
#define vi vector<int> 
#define vvi vector<vector<int>>
#define PI 3.14159265358979323846
using namespace std;
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
const int N=2e5+5;

void test_case()
{
  int n;
  cin>>n;
  map<int,int> m;
  int ans=0;
  rep(i,0,n ){
    int x; cin>>x;
    ++m[x];
    ans+=i+1-m[x];
    // ++m[x];
  }
  cout<< ans;
}
signed main()
{
  fast_io;
  #ifdef SIEVE
    sieve();
  #endif
  #ifdef NCR
    init();
  #endif
  int t=1;
  // cin>>t;
  rep(i,0,t){
  //cout<< "Case #" << i+1 << ": ";
         test_case();
  }
  return 0;
}
//taskkill -im main.exe -f