#include <bits/stdc++.h>
auto& in = std::cin;
auto& out = std::cout;
const double PI =
    3.141592653589793238462643383279502884197169399375105820974944;
int32_t N;
uint64_t M;
uint64_t A[100000];
int main() {
  using std::endl;
  in.sync_with_stdio(false);
  out.sync_with_stdio(false);
  in.tie(nullptr);
  out.tie(nullptr);
  in >> N >> M;
  for (int32_t i = 0; i < N; i++) {
    in >> A[i];
    A[i] %= M;
  }
  for (int32_t i = 0; i < N; i++) {
    A[i + 1] += A[i];
    A[i + 1] %= M;
  }
  std::unordered_map<int32_t, int32_t> num;
  for (int32_t i = 0; i < N; i++) {
    ++num[A[i]];
  }
  ++num[0];
  uint64_t res = 0;
  for (auto& c : num) {
    auto len = c.second;
    res += len * (len - 1) / 2;
  }
  out << res << endl;
  return 0;
}
