#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test() int t; cin>>t; while(t--)
#define all(v) v.begin(),v.end()
#define st(v) sort(all(v))
#define stA(arr,n) sort(arr,arr+n)
#define dps(n,c) vector<vector<ll>> dp(n,vector<ll>(c,0))
#define vc(v,n,f) vector<ll> v(n,f)
#define vct(v) vector<ll> v
#define findInVec(v,key) (find(all(v),key)!=v.end())
#define findInSet(v,key) (v.find(key) != v.end())
#define findInStr(s,key) (s.find(key) != string::npos)
#define findInMap(m,key) (mp.find(key) != mp.end())
#define prt(i) cout<<i<<"\n"
#define fos(v) for(auto x:v)
#define fo(m,n,i) for(int i=m;i<n;i++)
#define Fo(m,n,i) for(int i=m;i>n;i--)
#define setbit(i) __builtin_popcount(i)
#define del(v,pos) v.erase(v.begin()+pos)
#define cnt(v,key) (count(all(v),key))
#define cnts(s,key) (s.count(key))
#define sumArr(a,s,e,sum)(accumulate(a+s,a+e,sum))
#define pb(c) push_back(c);
#define mod 1000000007
typedef long long ll;
using namespace std;
template <typename Kausi>
void debug(vector<Kausi> v){cout<<"v = [ ";ll n=v.size();fo(0,n,i){cout<<v[i];if(i<n-1)", ";}cout<<" ]\nlength = "<<v.size()<<"\n";}
ll stringToLong(string s){stringstream raaz(s);ll x = 0;raaz >> x;return x;}
string longToString(ll k){stringstream ss;ss<<k;string s; ss>>s; return s;}
bool isPowerOfTwo(int n){if(n==0) return false; return (ceil(log2(n)) == floor(log2(n)));}
void scanArr(int *arr,int n){fo(0,n,i) cin>>arr[i];}
void printArr(int *arr,int n){fo(0,n,i) cout<<arr[i]<<" ";}
template <typename Kausi>
void scanVector(vector<Kausi> &v,int n){fo(0,n,i){Kausi temp;cin>>temp;v.push_back(temp);}}
template <typename Kausi>
void printVector(vector<Kausi> v){fos(v) cout<<x<<" ";}
int main()
{
	IOS
    ll n;
    cin>>n;
    vector<ll> v(n);
    map<ll,ll> mp;
    fo(0,n,i){ 
        cin>>v[i];
        mp[v[i]]++;
    }
    ll ans=0;
    fo(0,n,i)
    {
        mp[v[i]]--;
        ll curr = mp[v[i]];
        ans+=(n-i-1-curr);
    }
    prt(ans);
    return 0;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
template <typename T>
using orderedSet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using orderedMultiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld pi = 4.0 * atan(1.0);
#define xlr8                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);                   \
	cout.precision(10);               \
	cout << fixed

//76149
template <int D, typename T>
struct Vec : public vector<Vec<D - 1, T>>
{
	static_assert(D >= 1, "Vector dimension must be greater than zero!");
	template <typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...))
	{
	}
};
template <typename T>
struct Vec<1, T> : public vector<T>
{
	Vec(int n = 0, T val = T()) : vector<T>(n, val)
	{
	}
};

int main()
{
	xlr8;
	int testCases = 1;
	// cin >> testCases;
	while (testCases--)
	{
		int n;
		cin>>n;
		vector<int> a(n);
		map<int ,int> freq;
		for(int i = 0 ; i < n  ; i++)
			{
				cin>>a[i];
				freq[a[i]]++;
			}
		ll ans = 0;
		for(auto & k : freq)
		{
			ans += (1LL*k.second* (n - k.second));
		}
		cout<<ans/2<<"\n";
		


	}
}