#include <bits/stdc++.h>
using namespace std;
inline void rd(unsigned long long &x) {
  unsigned long long f = 1;
  x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  x *= f;
}
void pt(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) pt(x / 10);
  putchar(x % 10 + 48);
}
unsigned long long n, m, a[100010], ba = 127301;
unsigned long long ans;
unsigned long long dfs(unsigned long long l, unsigned long long rr) {
  unsigned long long b[201000];
  memset(b, 0, sizeof(b));
  if (l == rr) {
    if (a[l] % m) return 0;
    return 1;
  }
  unsigned long long mid = (l + rr) >> 1;
  unsigned long long mx = dfs(l, mid), my = dfs(mid + 1, rr);
  unsigned long long s = 0;
  for (register unsigned long long i = mid; i >= l; i--) {
    s += a[i];
    b[(s % m) % ba]++;
  }
  s = 0;
  for (register unsigned long long i = mid + 1; i <= rr; i++) {
    s += a[i];
    unsigned long long kk = (m - (s % m)) % m;
    mx += b[kk % ba];
  }
  return mx + my;
}
int main() {
  rd(n), rd(m);
  for (register unsigned long long i = 1; i <= n; ++i) rd(a[i]), a[i] %= m;
  cout << dfs(1, n);
}
