#include <bits/stdc++.h>
int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<long long int> box(n + 1, 0);
  for (auto i = 1; i <= n; ++i) std::cin >> box[i];
  for (auto i = 1; i <= n; ++i) {
    box[i] = (box[i] + box[i - 1]) % m;
  }
  std::sort(box.begin(), box.end());
  int left{0}, right{0};
  long long int sum{0};
  while (left <= n) {
    while (right <= n && box[right] == box[left]) {
      ++right;
    }
    sum += (right - left) * (right - left - 1) / 2;
    left = right;
  }
  std::cout << sum << std::endl;
}
