#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> v;
  v.push_back(0);
  for (int i = 0; i < n; ++i) {
    ll temp;
    cin >> temp;
    v.push_back((temp + v.at(i)) % m);
  }
  sort(v.begin(), v.end());
  ll test = v.at(0);
  ll g = 0;
  ll res = 0;
  v.push_back(m);
  for (int i = 1; i <= n; ++i) {
    if (test == v.at(i)) {
      g++;
    } else {
      test = v.at(i);
      res += (g * (g - 1)) / 2;
      g = 0;
    }
  }
  cout << res << endl;
  return 0;
}
