#include <bits/stdc++.h>
int main() {
  uint64_t n, m;
  std::cin >> n >> m;
  std::vector<uint64_t> a(n);
  std::vector<uint64_t> sum(m, 0);
  std::vector<uint64_t> sum2(m, 0);
  uint64_t s = 0;
  for (auto &i : a) {
    std::cin >> i;
    i %= m;
    s += i;
    s %= m;
    sum[s]++;
  }
  s = 0;
  uint64_t count = 0;
  for (auto &i : a) {
    count += sum[s] - sum2[s];
    s += i;
    s %= m;
    sum2[s]++;
  }
  std::cout << count << std::endl;
  return 0;
}
