#include <bits/stdc++.h>
int compare(const void *a, const void *b) {
  int ia = *(int *)a;
  int ib = *(int *)b;
  return ia - ib;
}
int main() {
  static int aa[100000 + 1];
  int n, m, i, j;
  long long ans;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    scanf("%lld", &aa[i]), aa[i] = (aa[i] + aa[i - 1]) % m;
  qsort(aa, n + 1, sizeof *aa, compare);
  ans = 0;
  for (i = 0; i <= n; i = j) {
    j = i + 1;
    while (j <= n && aa[j] == aa[i]) j++;
    ans += (j - i) * (j - i - 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}
