#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
long long a=1;
cin>>N;
vector<int> A(N);
for(int i=0;i<N;i++){
cin>>A[i];
}
vector<int> B(N+1,0);
B[A[0]]++;
for(int i=1;i<N;i++){
if(A[i]!=A[i-1]){
a+=i-B[A[i]];
}
B[A[i]]++;
}
cout<<a;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: