#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;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define int long long
#define reset(x) memset(x,0,sizeof(x))
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define all(a) a.begin(),a.end()
#define PI 3.1415926535897932384626433832795
#define INF 1000000000
#define MOD 1000000007
#define MOD2 1000000009
#define EPS 1e-6 
#define pb push_back
#define fi first
#define se second
#define mp make_pair
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};


signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
    int n; cin >> n;
    vector<int> arr;
    for (int i = 1; i <= n; i++)
    {
    	int x; cin >> x;
    	arr.pb(x);
    }
    sort(all(arr));
    int total = n * (n - 1) / 2;
    for (int i = 0; i < n; i++)
    {
    	int cnt = 1, ni = i;
    	for (int j = i + 1; j < n; j++)
    	{
    		if (arr[j] == arr[i])
    		{
    			cnt++;
    			ni = j;
    		}
    		else
    		{
    			break;
    		}
    	}
    	i = ni ;
    	total -= (cnt * (cnt - 1) / 2);
    }
    cout << total;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
//xd
int main(){
    long long int n;
    cin>>n;
    map<long long int,long long int> frecuencias;
    vector<int> actualnum; 
    int actual_size=-1;
    while(n--)
    {
        long long int temp;
        cin>>temp;
        if(!(frecuencias.find(temp)!=frecuencias.end()))
        {
            actualnum.push_back(temp);
        }
        frecuencias[temp]++;
        actual_size++;
    }
    long long int cont=0;
    for(auto it = actualnum.begin(); it != actualnum.end(); ++it)
    {
        cont+=frecuencias[*it]*(actual_size-(frecuencias[*it]-1));
        actual_size-=frecuencias[*it];
    }
    cout<<cont<<endl;
    return 0;
}