#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e19;
const int mod = 1000000000 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  vector<int> c(m + 1, 0);
  for (int i = 0; i < n; i++) cin >> a[i], c[a[i]]++;
  long long ans = 0;
  for (int i = 0; i < n; i++) ans += n - c[a[i]];
  cout << ans / 2 << endl;
  return 0;
}
