#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> la;
  vector<long long> lb;
  int s = 0;
  lb.push_back(s);
  map<long long, int> counts;
  counts[s] = 1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    la.push_back(a);
    s += a;
    assert(s >= 0);
    s %= m;
    assert(s >= 0);
    lb.push_back(s);
    if (counts.find(s) == counts.end()) {
      counts[s] = 0;
    }
    ++counts[s];
  }
  long long ans = 0;
  for (auto itr : counts) {
    int c = itr.second;
    ans += (c - 1) * c / 2;
  }
  cout << ans << endl;
}
