#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long M;
  cin >> N >> M;
  long A[N];
  long B[N];
  map<long, int> m;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i] = A[i];
    if (i != 0) B[i] += B[i - 1];
    if (!m.count(B[i] % M))
      m.insert({B[i] % M, 1});
    else
      m.at(B[i] % M)++;
  }
  long ans = 0;
  auto itr = m.begin();
  while (itr != m.end()) {
    int v = itr->second;
    if (!itr->first) ans += v;
    ans += v * (v - 1) / 2;
    ++itr;
  }
  cout << ans << endl;
  return 0;
}
