#include <bits/stdc++.h>
using namespace std;
template <typename P, typename Q>
ostream& operator<<(ostream& os, pair<P, Q> p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "(";
  for (auto& i : v) os << i << ",";
  os << ")";
  return os;
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  while (cin >> n >> m) {
    vector<long long int> a(n);
    for (auto& i : a) cin >> i;
    map<long long int, int> cnt;
    vector<long long int> v;
    for (int i = 0; i < a.size(); ++i) {
      if (i)
        v.push_back(v.back() + a[i]);
      else
        v.push_back(a[i]);
      v.back() %= m;
      ++cnt[v.back()];
    }
    long long int sum = cnt[0];
    for (auto& i : cnt) {
      sum += i.second * (i.second - 1) / 2;
    }
    cout << sum << endl;
  }
  return 0;
}
