#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  ll n, m;
  cin >> n >> m;
  ll sum = 0;
  map<int, int> memo;
  ll tmp = 0;
  memo.insert(make_pair(0, 1));
  for (auto i = 0; i < n; i++) {
    cin >> tmp;
    sum = (sum + tmp) % m;
    int r = (int)(sum % m);
    auto q = memo.find(r);
    if (q == memo.end())
      memo.insert(make_pair(r, 1));
    else
      q->second++;
  }
  ll res = 0;
  for (auto q : memo) {
    if (q.second > 1) {
      res += (q.second * (q.second - 1)) / 2;
    }
  }
  cout << res << endl;
  return 0;
}
