#include <bits/stdc++.h>
int upll(const void* a, const void* b) {
  return *(long long*)a < *(long long*)b   ? -1
         : *(long long*)a > *(long long*)b ? 1
                                           : 0;
}
void sortup(long long* a, int n) { qsort(a, n, sizeof(long long), upll); }
long long a[100010];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int t;
    scanf("%d", &t);
    a[i + 1] = (a[i] + t) % m;
  }
  sortup(a, n + 1);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long t = 1;
    while (a[i + t] == a[i]) t++;
    ans += t * (t - 1) / 2;
    i = i + t - 1;
  }
  printf("%lld", ans);
}
