#include <bits/stdc++.h>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using namespace std;
int main() {
  ll N;
  ll M;
  cin >> N >> M;
  ll A[N];
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll B[N + 1];
  B[0] = 0;
  for (ll i = 1; i <= N; i++) {
    B[i] = (B[i - 1] + A[i - 1]) % M;
  }
  map<ll, ll> bucket = map<ll, ll>();
  for (ll i = 0; i <= N; i++) {
    ll m = B[i];
    if (bucket.count(m) == 0) {
      bucket[m] = 0;
    }
    bucket[m] += 1;
  }
  ll count = 0;
  for (const auto& [key, value] : bucket) {
    count += (value) * (value - 1) / 2;
  }
  cout << count << endl;
}
