#include <bits/stdc++.h>
using namespace std;
int main() {
  uint64_t n, m;
  cin >> n >> m;
  vector<uint64_t> v;
  v.push_back(0);
  for (uint64_t i = 0; i < n; i++) {
    uint64_t x;
    cin >> x;
    v.push_back(x);
  }
  for (uint64_t i = 1; i < v.size(); i++) {
    v[i] += v[i - 1];
  }
  unsigned long long tot = 0;
  map<unsigned long long, unsigned long long> mp;
  for (int i = 1; i < v.size(); i++) {
    mp[v[i] % m] = mp[v[i] % m] + 1;
    if (v[i] % m == 0) {
      tot++;
    }
  }
  for (auto item : mp) {
    unsigned long long it = item.second;
    tot += it * (it - 1l) / 2;
  }
  cout << tot;
  return 0;
}
