#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(m);
  long long sum1 = 0;
  long long sum2 = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++a[x - 1];
  }
  for (int i = 0; i < m; ++i) {
    sum1 += a[i];
    sum2 += a[i] * a[i];
  }
  sum1 *= sum1;
  cout << (sum1 - sum2) / 2;
  return 0;
}
