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

#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 pq_max             priority_queue<int>
#define pq_min             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--)
#define f(i,s,n)        for(int i=s;i<n;i++)
#define all(x)              (x).begin(),(x).end()
#define allr(c)             (c).rbegin(), (c).rend()
#define sz(x) ((int)(x).size())
#define itr_v(v)                 for(int i=0;i<sz(v);i++)
#define itr_str(s)               for(int i=0;i<s.length();i++)
#define endl ("\n")
#define ip(v)               for(auto& i:v)    cin>>i;
#define ip_2d(a)            for(auto &v:a)  for(auto &x:v)  cin>>x;
#define sumv(a) accumulate(all(a),0)
#define yn(x) ((x)?"YES":"NO")
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ci(X)               int X; cin>>X
#define cii(X, Y)           int X, Y; cin>>X>>Y
#define ciii(X, Y, Z)       int X, Y, Z; cin>>X>>Y>>Z
#define ciiii(W, X, Y, Z)   int W, X, Y, Z; cin>>W>>X>>Y>>Z
template <typename T> void out(T t) { cout << t << endl; }

#define dbg(x)              cout<<#x<<"="<<(x)<<endl;
#define dbg2(x,y)           cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl;
#define dbg3(x,y,z)         cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<" "<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w)       cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<" "<<#z<<"="<<(z)<<" "<<#w<<"="<<(w)<<endl;

void io()
{
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

long long binpow(long long val, long long deg, long long m) {
  if (!deg) return 1 % m;
  if (deg & 1) return binpow(val, deg - 1, m) * val % m;
  long long res = binpow(val , deg >> 1, m);
  return (res * res) % m;
}

// int fact[1000010];
// void initfact(int N) {
//   fact[0] = 1;
//   for (int i = 1; i < N; i++) {
//     fact[i] = (fact[i - 1] * i);
//     fact[i] %= mod;
//   }
// }


// long long nCr(int n, int i) {
//   long long res = fact[n];
//   long long div = fact[n - i] * fact[i];
//   div %= mod;  div = binpow(div, mod - 2, mod);
//   return (res * div) % mod;
// }

void print(vi a)
{
  for (int i = 0; i < sz(a); i++)
    cout << a[i] << " ";
  cout << endl;
}

void print_2d(vector<vi> &a)
{
  const int n = sz(a), m = sz(a[0]);
  f(i, 0, n)
  {
    f(j, 0, m)
    {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
}

bool isPrime(int n)
{
  if (n == 1) return false;
  if (n == 2) return true;
  if (n == 3) return true;
  f(i, 2, sqrt(n) + 1) if (n % i == 0) return false;
  return true;
}

void SieveOfEratosthenes(int n)
{
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));

  for (int p = 2; p * p <= n; p++)
  {
    if (prime[p] == true)
    {
      for (int i = p * p; i <= n; i += p)
        prime[i] = false;
    }
  }

  for (int p = 2; p <= n; p++)
    if (prime[p])
      cout << p;
}

void rotate_anti_2d(vector<vi> &a)
{
  const int n = sz(a), m = sz(a[0]);
  vector<vi> b(m, vi(n));
  int i, j;
  f(i, 0, n) f(j, 0, m) b[m - 1 - j][i] = a[i][j];
  a.swap(b);
}

void ap_18()
{
  ci(n);
  vi a(n);
  ip(a);
  mii m;
  for(int i=0;i<n;i++)
  {
    m[a[i]]++;
  }
  int ans=0;
  for(auto it:m)
  {
    ans+=((it.ss)*(n-it.ss));
  }
  out(ans/2);
}
int32_t main()
{
  io();
  ap_18();
  return 0;
}
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define inp(arr, n)                                                            \
  for (ll i = 0; i < (ll)n; i++)                                               \
    cin >> arr[i];
#define fori(i, a, b) for (ll i = a; i < (ll)b; i++)
#define forib(i, a, b) for (ll i = a; i >= (ll)b; i--)
#define printarr(i, n, arr)                                                    \
  for (ll i = 0; i < n; i++)                                                   \
    cout << arr[i] << " ";
#define test(x)                                                                \
  ull x;                                                                       \
  cin >> x;                                                                    \
  while (x--)
const ull mod = 1e9 + 7;
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ull n;
  cin >> n;
  ull arr[n];
  fori(i, 0, n) cin >> arr[i];
  sort(arr, arr + n);
  vector<ll> countArr;
  ll count = 1;
  fori(i, 1, n) {
    if (arr[i] == arr[i - 1])
      count++;
    else {
      countArr.pb(count);
      count = 1;
    }
  }
  countArr.pb(count);
  count = n * (n - 1) / 2;
  for (auto i : countArr) {
    count -= (i * (i - 1) / 2);
  }
  cout << count;
  return 0;
}
