#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];
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  S[0] = A[0] % M;
  for (i = 1; i < N; i++) {
    S[i] = (S[i - 1] + A[i]) % M;
  }
  qsort(S, N, sizeof(int), compare_int);
  int n = 1;
  for (i = 1; i < N; i++) {
    if (S[i] == S[i - 1]) {
      n++;
    } else {
      ANS = ANS + (n - 1) * n / 2;
      n = 1;
    }
  }
  ANS = ANS + n * (n - 1) / 2;
  i = 0;
  while (S[i] == 0) {
    i++;
  }
  ANS = ANS + i;
  printf("%lld", ANS);
  return 0;
}
