#include <bits/stdc++.h>
using namespace std;
void get() {}
long long a[123456];
map<long long, int> mp;
long long binomialCoeff(long long n, long long k) {
  long long res = 1;
  if (k > n - k) k = n - k;
  for (int i = 0; i < k; ++i) {
    res *= long long(n - i);
    res /= long long(i + 1);
  }
  return res;
}
class DCandyDistribution {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int n, m;
    in >> n >> m;
    mp.clear();
    memset(a, 0, sizeof(a));
    long long sum = 0;
    for (int i = 1; i <= n; ++i) {
      in >> a[i];
      if (i != 0) a[i] += a[i - 1];
      a[i] %= m;
      mp[a[i]]++;
    }
    for (auto it = mp.begin(); it != mp.end(); ++it) {
      if (it->second >= 2 && it->first != 0)
        sum += binomialCoeff(it->second, 2), cerr << sum << " ";
      else if (it->first == 0)
        sum += binomialCoeff(it->second, 2) + it->second, cerr << sum << " ";
    }
    out << sum << endl;
  }
};
int main() {
  DCandyDistribution solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
