#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 5;
const long long MAX_N = 2e5 + 5;
const long long MODD = 1e9 + 7;
const long long BITS = 10;
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
double max(double a, double b) { return a > b ? a : b; }
double min(double a, double b) { return a < b ? a : b; }
long long modd(long long a) {
  if (a < 0LL) return a * -1LL;
  return a;
}
double modd(double a) {
  if (a < 0.0) return a * -1.0;
  return a;
}
long long modulo(long long a) { return (a + MODD) % MODD; }
void swap(long long &a, long long &b) {
  long long t = a;
  a = b;
  b = t;
}
long long power(long long k, long long p) {
  if (p == 0) return 1LL;
  long long P = power(k, p / 2LL);
  P = (P * P) % MODD;
  if (p % 2 == 1) P = (P * k) % MODD;
  return P;
}
int iii = 0;
void _debug() { cout << "here " << (iii++) << endl; }
void solve() {
  long long n, m;
  cin >> n >> m;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long cnt[m + 5];
  memset(cnt, 0, sizeof(cnt));
  for (long long i = 0; i < n; i++) {
    cnt[a[i]]++;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    cnt[a[i]]--;
    long long val = n - i - 1;
    val -= cnt[a[i]];
    val = max(0, val);
    ans += val;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  for (long long i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
