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