#include <bits/stdc++.h>
using namespace std;
long long r, n, m, ans = 0, now = 0, nextn = 0;
map<long long, long long> mp;
vector<long long> a;
int main() {
  long long i;
  cin >> n >> m;
  for (i = 0; i < n; ++i) {
    cin >> r;
    now += r;
    now %= m;
    if (mp.find(now) == mp.end())
      mp[now] = 1;
    else
      ++mp[now];
    a.push_back(r % m);
  }
  nextn = 0;
  for (i = n - 1; i >= 0; --i) {
    if (mp.find((m - nextn) % m) != mp.end() && mp[(m - nextn) % m] > 0)
      ans += mp[(m - nextn) % m];
    nextn += a[i];
    nextn %= m;
    now = (m + now - a[i]) % m;
    --mp[now];
  }
  cout << ans << endl;
  return 0;
}
