#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A;
  A.push_back(0);
  for (long long i = 0; i < N; i++) {
    long long x;
    cin >> x;
    A.push_back((A[i + 1] + x) % M);
  }
  map<long long, long long> m;
  for (long long i = 0; i < A.size(); i++) {
    if (m.find(A[i]) != m.end())
      m[A[i]]++;
    else
      m.insert(make_pair(A[i], 1));
  }
  long long ans = 0;
  for (auto itr = m.begin(); itr != m.end(); itr++) {
    ans += (itr->second) * (itr->second - 1);
  }
  cout << ans << endl;
  return 0;
}
