#include <bits/stdc++.h>
int N, M;
int A[200000 + 5];
int Sum[200000 + 5][10 + 5];
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
    for (int j = 1; j <= M; j++) Sum[i][j] += Sum[i - 1][j];
    Sum[i][A[i]]++;
  }
  int Ans = 0;
  for (int i = 1; i <= N; i++) Ans += N - i - Sum[N][A[i]] + Sum[i][A[i]];
  printf("%d", Ans);
}
