For this Question: Given an array of N integers. Find the number of pairs (i, j) of integers satisfying all of the following conditions:
1 &le; i < j &le; N
A<sub>i</sub> &ne; A<sub>j</sub>
​The first line of the input consists of an integer N. The second line consists of N space separated integers.

<b>Constraints</b>
All values in input are integers.
2 &le; N &le; 3×10^5
1 &le; A<sub>i</sub> &le; 10^9Print the answer as an integer.<b>Sample Input 1</b> 
3
1 7 1
<b>Sample Output 1</b> 
2

<b>Sample Input 2</b>
10
1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000
<b>Sample Output 2</b> 
45, I have written this Solution Code: #include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  vector<int> a(n);
  for(auto &nx : a){cin >> nx;}
  long long res1=(n*(n-1)/2),res2=0;
  
  map<int,long long> mp;
  for(int i=0;i<n;i++){mp[a[i]]++;}
  for(int i=0;i<n;i++){res2+=(n-mp[a[i]]);}
  res2/=2;
  
  sort(a.begin(),a.end());
  a.push_back(-1);
  long long cnt=1;
  for(int i=0;i<n;i++){
    if(a[i]!=a[i+1]){
      res1-=((cnt*(cnt-1))/2);
      cnt=1;
    }
    else{cnt++;}
  }
  assert(res1==res2);
  cout << res1 << '\n';
  //cout << res2 << '\n';
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?