#include <bits/stdc++.h>
using namespace std;
class DCandyDistribution {
 public:
  void solve(std::istream& cin, std::ostream& cout) {
    int n, m;
    cin >> n >> m;
    vector<int64_t> A(n);
    for (auto& a : A) cin >> a;
    vector<int64_t> acc(n + 1);
    acc[0] = 0;
    partial_sum(A.begin(), A.end(), acc.begin() + 1);
    int64_t ans = 0;
    map<int64_t, int> C;
    for (const auto& a : acc) C[a % m]++;
    for (const auto& c : C) ans += c.second * (c.second - 1) / 2;
    cout << ans << endl;
  }
};
int main() {
  DCandyDistribution solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
