#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve(long long N, long long M, std::vector<long long> A) {
  ll sum = 0;
  map<ll, ll> occur;
  occur[0] = 1;
  for (ll i = 0; i < N; i++) {
    sum = (sum + A[i]) % M;
    occur[sum] = occur[sum] + 1;
  }
  ll res = 0;
  for (const auto& [key, value] : occur) {
    res += value * (value - 1) / 2;
  }
  cout << res << endl;
}
int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, M, std::move(A));
  return 0;
}
