#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int a[100001];
  for (int i = 0; i < n; ++i) {
    int b;
    scanf("%d", &b);
    a[i + 1] = (a[i] + b) % m;
  }
  a[n] = 0;
  std::sort(a, a + n + 1);
  long long ans = 0;
  for (int l = 0; l < n + 1;) {
    int r = std::upper_bound(a + l, a + n + 1, a[l]) - a;
    ans += (r - l) * (r - l - 1) / 2;
    l = r;
  }
  printf("%lld\n", ans);
  return 0;
}
