#include <bits/stdc++.h>
int chooseTwo(int n) { return (n * (n - 1)) >> 1; }
int main() {
  int n, m;
  std::cin >> n >> m;
  long sum = 0;
  std::map<int, int> modmap;
  for (int i = 0; i < n; ++i) {
    int b;
    std::cin >> b;
    sum += b;
    int r = sum % m;
    if (modmap[r]) {
      ++modmap[r];
    } else {
      modmap[r] = 1;
    }
  }
  int res = modmap[0];
  for (auto p = modmap.begin(); p != modmap.end(); ++p) {
    if (p->second > 1) {
      res += chooseTwo(p->second);
    }
  }
  std::cout << res << std::endl;
  return 0;
}
