#include<bits/stdc++.h>
using namespace std;
int N;
int a[300005];
map<long long,int>mp;
long long cnt,ans=0;
int main()
{
	cin>>N;
	for(int i=1;i<=N;i++)
	{cin>>a[i];
	mp[a[i]]++;
	}
	if(mp[a[1]]==N){cout<<"0";return 0;}//�״��� 
	for(auto &v:mp)ans+=(long long)v.second*(v.second-1)/2;//v.secondΪ���ͣ���ǿ�� 
	cnt=(long long)N*(N-1)/2-ans;//NΪ���ͣ���Ҫǿ��תΪlonglong 
	cout<<cnt;
	return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define N               100004
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}


int32_t main()
{
  c_p_c();
  int n; cin >> n;
  int *arr = new int[n + 1];
  for (int i = 1; i <= n; i++)
    cin >> arr[i];
  map<int, vector<int>>m;
  for (int i = 1; i <= n; i++)
    m[arr[i]].pb(i);
  int ans = 0;
  for (int i = 1; i <= n; i++)
  {
    int ind = m[arr[i]].end() - upper_bound(m[arr[i]].begin(), m[arr[i]].end(), i);

    ans += (n - i) - ind;
    //cout << ans << endl;
  }
  cout << ans << '\n';

  return 0;

}