#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	long long N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end());
	long long ans = 0;
	long long start = 0, end = 1;
	while (end < N) {
		if (A[start] != A[end]) {
			ans += (end-start)*(N - end);
			start = end;
			end = start + 1;
			continue;
		}
		end++;
	}
	cout << ans << endl;
	return 0;
}
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;

#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll>>
#define iint int
#define f(i,a,b)        for(ll i=a;i<b;i++)
#define f0(i,n)         f(i,0,n)
#define fr(i,a,b)       for(ll i=a;i>=b;i--)
#define for1(i,n)       for(ll i=1;i<=n;i++)
#define pb              push_back
#define tc(t)           int t;cin >>t;while(t--)
#define lol             std::ios::sync_with_stdio(false); cin.tie(NULL);
#define endl            "\n"
#define ss              second
#define ff              first
#define ll              long long
#define lld             long double
#define int             long long
#define pii             pair< int,int >
#define pll             pair< ll,ll >
#define sz(a)           a.size()
const long long  inf = 1e18;
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define arr(a,n)        int a[n];f0(i, n) cin >> a[i];
#define ini(a,n)        memset(a,n,sizeof(a))
#define printArr(a,n)   f0(i,n) cout<<a[i]<<" ";
// #define in              cin>>
#define rr              return 0;
#define vi              vector< int >
#define vs              vector<string>
#define l_b             lower_bound
#define u_b             upper_bound
#define mod             1000000007
#define pi              3.141592653589793238
#define fmap(m)         for(auto it:m)
#define deb(args...)    { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define debarr(arr,a,b) for(int i=(a);i<(b);i++) cout<<(arr[i])<<" ";cout<<endl;
#define long_max        numeric_limits<ll>::max()
vs tokenizer(string str, char ch) {std::istringstream var((str)); vs v; string t; while (getline((var), t, (ch))) {v.pb(t);} return v;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}


int dx[8] = { +1, +1, +1, 0, 0, -1, -1, -1};
int dy[8] = { +1, 0, -1, +1, -1, +1, 0, -1};

int dx4[4] = { +1 , -1 , +0 , +0};
int dy4[4] = { 0  , 0 , +1 , -1};

int dx2[2] = {0, 1};
int dy2[2] = {1, 0};

const int N = 1e6 + 1;



void solve()
{

    int n;
    cin >> n;
    arr(a, n);
    map<int, int>m;
    f0(i, n)
    m[a[i]]++;
    int ans = 0 ;
    for (int i = 0; i < n - 1; i++)
    {
        int element = n - i - m[a[i]];
        // deb(element);
        m[a[i]]--;

        ans += max(0ll , element);
    }
    cout << ans << "\n";
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    lol;

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}
