#include <bits/stdc++.h>
using namespace std;
const int MD = (int)1e9 + 7;
void dbg() { cerr << "\n"; }
template <typename T, typename... T2>
void dbg(const T& fst, const T2&... rst) {
  cerr << fst << ": ";
  dbg(rst...);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> a(n), sm(n + 1);
  for (int(i) = 0; (i) < (n); (i)++) cin >> a[i];
  for (int(i) = 0; (i) < (n); (i)++) (sm[i + 1] = sm[i] + a[i]) %= m;
  map<long long, int> mp;
  for (int(i) = 0; (i) < (n + 1); (i)++) mp[sm[i]]++;
  long long ans = 0;
  for (auto x : mp)
    if (x.second > 1) {
      ans += (x.second * (x.second - 1)) / 2;
    }
  cout << ans << "\n";
  return 0;
}
