//-------------------------------------
//| -<{ Besme llahe Rahmane Rahim }>- |
//-------------------------------------
#include <bits/stdc++.h>
#define pb push_back
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz(x) (int)(x).size()
#define all(c) (c).begin(),(c).end()
using namespace std;
//#include ".dbg.h"
typedef long long ll;
const int N = 300005;
ll n, cnt = 1, ans;
int a[N];

void solve(){
    ans = n * (n-1) / 2;
    sort(a, a + n);
    for(ll i = 1; i < n; i++)
    {
        if(a[i] == a[i-1]) cnt++;
        if(a[i] != a[i-1] || i == n-1)
        {
            ans -= (cnt * (cnt - 1) / 2);
            cnt = 1;
        }
    }
}

int main(){
    cin >> n; for(int i = 0; i < n; i++) cin >> a[i];
    solve();
    cout << ans;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)//iをaからn
#define per(i,n,a) for (int i=a-1;i>=n;i--)//iをnからa
#define db(x) cout << #x << " = " << x << endl
#define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用
#define all(x) (x).begin(), (x).end()
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define pb push_back
#define F first
#define S second
typedef long long ll;
//sort(all(a)); ソート
//sort(all(a),greater<int>()); 逆順ソート
//a.erase(unique(all(a)), a.end()); ソート後に重複を削除
//cout<< std::fixed << std::setprecision(15)<<0.000001<<endl; 小数点以下を表示させる
//vector<vector<int>> data(3, vector<int>(4)); int型の2次元配列(3×4要素の)の宣言


int main() {
ll n;
cin>>n;
vector<ll> a(n+1);
ll ans=0;
    rep(i,0,n){
        cin>>a.at(i);
    }
    a.at(n)=MOD;
    sort(all(a));
    ll last=0;
    rep(i,0,n-1){
        if(a.at(i)!=a.at(i+1)){
            //cout<<i<<" "<<a.at(i)<<" "<<i+1<<" "<<a.at(i+1)<<endl;
            last=i+1;
        }else{
            
        }
        ans+=last;
    }
    cout<<ans;
    return 0;
}