#include <bits/stdc++.h>
int main() {
  int n, m;
  int sum = 0;
  std::unordered_map<int, int> countMap;
  std::cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a;
    std::cin >> a;
    sum = (sum + a) % m;
    auto itr = countMap.find(sum);
    if (itr != countMap.end()) {
      countMap[sum]++;
    } else {
      countMap[sum] = 1;
    }
  }
  long long ans = 0;
  for (auto itr = countMap.begin(); itr != countMap.end(); ++itr) {
    int x = itr->second;
    ans += x * (x - 1) / 2;
    if (itr->first == 0) {
      ans += x;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
