#include <bits/stdc++.h>
int compare_int(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
  int i, N, M;
  long long ANS = 0;
  scanf(
      "%d"
      "%d",
      &N, &M);
  int A[N], S[N + 1];
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  S[0] = 0;
  int s = 0;
  for (i = 0; i < N; i++) {
    s = (s + A[i]) % M;
    S[i + 1] = s;
  }
  qsort(S, N + 1, sizeof(int), compare_int);
  int n = 1;
  for (i = 0; i < N; i++) {
    if (S[i + 1] == S[i]) {
      n++;
    } else {
      ANS += (n - 1) * n / 2;
      n = 1;
    }
  }
  ANS += n * (n - 1) / 2;
  printf("%lld", ANS);
  return 0;
}
