#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ans = 0, x;
  cin >> n >> m;
  vector<vector<int> > a(m + 1);
  for (int i = 1; i <= n; i++) {
    cin >> x;
    a[x].push_back(i);
  }
  ans = 0;
  for (int i = 1; i <= m; i++)
    for (int j = i + 1; j <= m; j++) ans += (a[i].size() * a[j].size());
  cout << ans;
  return 0;
}
