#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> b(n + 1, 0);
  map<long long, long long> s;
  s.insert(make_pair(0, 1));
  for (int i = 1; i <= n; i++) {
    b[i] = (b[i - 1] + a[i]) % m;
    if (s.count(b[i]) == 0) {
      s.insert(make_pair(b[i], 1));
    } else {
      s.at(b[i])++;
    }
  }
  long long ans = 0;
  for (auto itr = s.begin(); itr != s.end(); itr++) {
    ans += ((*itr).second - 1) * (*itr).second / 2;
  }
  cout << ans << endl;
  return 0;
}
