#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;
  }
  A[N] = 0;
  std::sort(A, A + N + 1);
  uint64_t res = 0;
  for (uint64_t i = 0; i < M; i++) {
    auto range = std::equal_range(A, A + N + 1, i);
    auto len = range.second - range.first;
    res += len * (len - 1) / 2;
  }
  out << res << endl;
  return 0;
}
