#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N + 1, 0);
  for (long long i = 0; i < N; ++i) {
    long long a;
    cin >> a;
    A.at(i + 1) = (A.at(i) + a) % M;
  }
  sort(A.begin(), A.end());
  long long cnt = 0;
  long long before = -1;
  long long ans = 0;
  for (long long i = 0; i < N; ++i) {
    if (A.at(i) == before) {
      cnt += 1;
    } else {
      ans += (cnt - 1) * cnt / 2;
      cnt = 1;
      before = A.at(i);
    }
  }
  ans += cnt * (cnt - 1);
  cout << ans << endl;
}
