#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int w = 1, c = 0;
  while (!isdigit(ch)) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    c = (c << 1) + (c << 3) + (ch ^ 48);
    ch = getchar();
  }
  return w * c;
}
map<int, int> mp;
long long m, n, ans;
long long a[500000], s[500000], ss[500000];
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++)
    a[i] = read(), s[i] += s[i - 1] + a[i], ss[i] = s[i] % m;
  for (int i = n; i > 0; i--) {
    if (s[i] > m) ans += mp[ss[i]] + (ss[i] == 0), mp[ss[i]]++;
  }
  cout << ans << "\n";
  return 0;
}
