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