#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define sz(a) a.size()
#define all(v) (v.begin(),v.end());
#define pb push_back
#define int long long
void solve() {
	int n;
	cin >> n;
	vi v(n);
	map<int, int> m;
	rep(i, 0, n) {
		cin >> v[i];
		m[v[i]]++;
	}

	int tot = n * (n - 1) / 2;
	for (auto x : m) {
		int temp = x.second;
		if (temp > 1) {
			tot -= (temp * (temp - 1) / 2);
		}
	}
	cout << tot << endl;
}
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();

}
#include <bits/stdc++.h>
#include <bits/extc++.h>

#define sz(v) int (v.size())
#define ff first
#define ss second
#define pb push_back
#define int long long
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int MOD = 1000000009;
mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());

double GetTime() { return clock() / (double) CLOCKS_PER_SEC; };
/// Actual code starts here
int n;
const int N = 100005;

void solve() {
    cin >> n;
    int res = 0;
    vector<int> v(n);
    for (auto &i : v) cin >> i;
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        cnt[v[i]]++;
        res += i - cnt[v[i]] + 1;
    }
    cout << res;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    int tt = 1;
    //cin >> tt;
    while (tt--)
        solve();
}
