//The moment you giveup , is the moment you let someone else win!!!
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define PI (3.141592653589)
#define seal(x,y) ((x+y-1)/y)
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define all(x) x.begin(),x.end()

int digit_sum(int n){
int sum=0;
while(n)
sum+=(n%10),n/=10;
return sum;
}

//int digicnt_fact(int n)
//{
//if(n<0) return 0;  //factorial doesn't exist
//if(n<=1) return 1; //base case
//double x=((n * log10(n / M_E) +log10(2 * M_PI * n) /2.0));  //Kamenetsky's formula
//return floor(x)+1;
//}
void solve(){
 int n;cin>>n;
 int a[n];
 rep(i,n)
 cin>>a[i];
 int ans=0;
 unordered_map<int,int> m;
 for(int i=n-1;i>=0;i--)
 {
     ans+=(n-1-i-m[a[i]]);
     m[a[i]]++;
 }
 cout<<ans;
}

int32_t main()
{
fast
int t=1;
//cin>>t;
while(t--){
solve();
}
return 0;
}
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <map>
#include<stack>
#include <cmath>

using namespace std;

char judge(string Input){
  if(Input=="RP" || Input=="PR"||Input =="PP")return 'P';  
  if(Input=="RS" || Input=="SR"||Input =="RR")return 'R';  
  if(Input=="PS" || Input=="SP"||Input =="SS")return 'S';  
}

void solve(){
  int n,k;
  scanf("%d %d",&n,&k);
  string Input,Output="",temp="";
  cin>>Input;
  while(k>0){
    Input = Input + Input;
    Output="";
    for(int i=0;i<Input.length();i+=2){
      temp= "";
      temp+=Input[i];
      temp+=Input[i+1];
      Output += judge(temp);
    }
    Input=Output;
    k--;
  }
  cout<<Input[0]<<endl;

}

int main()
{
  int t=1,i=1;
  //scanf("%d",&t);
  while(t--){
    //cout<<"Case #"<<i<<":";
    solve();
    i++;
  }
  return 0;
}