#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
const int M = 200010;
long long a[N],n,mk[N],res;
long long q[M];
int main(){
freopen("charger.in","r",stdin);
freopen("charger.out","w",stdout);
scanf("%lld",&n);
if(n<=5000){
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
for(int i=1;i<n;i++){
memset(mk,0,sizeof(mk));
for(int j=i+1;j<=n;j++){
if(a[j]==a[i])break;
if(mk[a[j]])continue;
res++;
mk[a[j]]++;
}
}
printf("%lld",res);
return 0;
}else{
for(int i=1;i<=n;i++)
scanf("%lld",&q[i]);
long long cnt=(n*(n-1))/2;
cout<<cnt;
return 0;
}
}