#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1 << 29;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool isnatural(double a) { return a >= 0 && ceil(a) == floor(a); }
template <typename T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  return a < b && (a = b, true);
}
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  return a > b && (a = b, true);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  for (int i = 0, len = v.size(); i < len; ++i) {
    s << v[i];
    if (i < len - 1) s << "\t";
  }
  return s;
}
template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T> >& vv) {
  for (int i = 0, len = vv.size(); i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& s, const map<T1, T2>& m) {
  s << "{" << endl;
  for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr) {
    s << "\t" << (*itr).first << " : " << (*itr).second << endl;
  }
  s << "}" << endl;
  return s;
}
signed main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> a(N, 0);
  for (int i = 0, i_length = (N); i < i_length; ++i) cin >> a[i];
  vector<ll> rui(N + 1, 0);
  for (int i = 0, i_length = (N); i < i_length; ++i)
    rui[i + 1] = (rui[i] + a[i]) % M;
  vector<ll> arr(M, 0);
  for (int i = 0, i_length = (N + 1); i < i_length; ++i) arr[rui[i]]++;
  ll ans = 0;
  for (int i = 0, i_length = (M); i < i_length; ++i) {
    if (arr[i] > 0) {
      ll t = arr[i];
      ans += t * (t - 1) / 2;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
