#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0), cout.precision(15);
  int n, m;
  cin >> n >> m;
  vector<int> cnt(m, 0);
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    cnt[ai - 1]++;
  }
  ll ans = 0;
  for (int i = 0; i < m; i++) {
    ans += cnt[i] * (n - cnt[i]);
  }
  ans /= 2;
  cout << ans << endl;
  return 0;
}
