#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
  unsigned long N, M;
  cin >> N >> M;
  vector<unsigned long> v(N, 0);
  vector<unsigned long> s(N + 1, 0);
  map<unsigned long, int> m;
  m.insert(make_pair(0, 1));
  for (int i = (0); i < (((int)N)); ++i) {
    cin >> v[i];
    s[i + 1] = s[i] + v[i];
    if (m.find(s[i + 1] % M) != m.end())
      m[s[i + 1] % M] = m[s[i + 1] % M] + 1;
    else
      m.insert(make_pair(s[i + 1] % M, 1));
  }
  int c;
  unsigned long ans = 0;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    c = (*itr).second;
    if (c > 1) ans += c * (c - 1) / 2;
  }
  cout << ans << endl;
}
