// Sakhiya07 - Yagnik Sakhiya
  
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()

#define pll pair<ll,ll>
#define ff first
#define ss second

#define MOD 1000000007

const int N = 100005; 

void solve() 
{
    ll n;
    cin >> n;
    map<ll,ll> y;
    ll ans = 0;
    for(ll i = 1 ; i <= n ; i++) {
        ll x;
        cin >> x;
        ans += (i-1-y[x]);
        y[x]++;
    }
    cout << ans;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int t = 1;

    for(int i = 1; i < t + 1; i++) {
        solve();
    }
    
}
#include <bits/stdc++.h>
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define PER(i,a,b) for (int i = (b); i >= (a); --i)
#define log2(x) (31-__builtin_clz(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SZ(x) (int)(x).size()
#define PB push_back
#define FI first
#define SE second
#define mup(x,y) x = min(x,y)
#define Mup(x,y) x = max(x,y)
#define debug(x) cout << #x << " is " << x << el
#define el '\n'
using namespace std; using ll = long long; using ii = pair<int,int>; using iii = tuple<int,int,int>;
void solution(); int main() {ios::sync_with_stdio(0); cin.tie(0); solution();}
const int N = 30'0005;
ll n;
int a[N];

void input() {
    cin >> n;
    REP(i,1,n) cin >> a[i];
}
void solution() {
    input();
    sort(a+1,a+n+1);
    ll x = n*(n+1)/2;
    ll cnt = 0;
    REP(i,1,n) {
        ++cnt;
        if (a[i] != a[i+1]) {
            x -= cnt*(cnt+1)/2;
            cnt = 0;
        }
    }
    cout << x;
}