#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N);
  for (int i = 0; i < (N); i++) cin >> A[i];
  vector<ll> sums(N + 1);
  sums[0] = 0;
  for (int i = 1; i <= N; i++) {
    sums[i] = sums[i - 1] + A[i - 1];
  }
  unordered_map<ll, int> mp;
  for (int i = 0; i < (N + 1); i++) mp[(sums[i]) % M]++;
  ll ans = 0;
  for (auto m : mp) {
    ans += m.second * (m.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
