#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> b(n + 1);
  map<long long, long long> mp{};
  for (long long i(0); i < n; ++i) {
    long long a;
    cin >> a;
    b[i + 1] = b[i] + a;
    long long t = b[i + 1] % m;
    if (mp.count(t) == 0) {
      mp[t] = 1;
    } else {
      mp[t]++;
    }
  }
  long long ans(0);
  for (auto i = mp.begin(); i != mp.end(); ++i) {
    long long p = i->second;
    if (p <= 1) continue;
    ans += p * (p - 1) / 2;
    if (i->first == 0) ans += p;
  }
  cout << ans << endl;
  return 0;
}
