#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  ll m;
  cin >> n >> m;
  vector<ll> a(n);
  for (int(i) = 0; (i) < (n); ++(i)) cin >> a[i];
  vector<ll> s(n + 1, 0);
  for (int(i) = 0; (i) < (n); ++(i)) s[i + 1] = s[i] + a[i];
  map<int, int> cnt;
  for (int(i) = 0; (i) < (n + 1); ++(i)) cnt[s[i] % m]++;
  ll ans = 0;
  for (auto e : cnt) {
    if (e.second % 2 == 0)
      ans += e.second / 2 * (e.second - 1);
    else
      ans += (e.second - 1) / 2 * e.second;
  }
  cout << ans << endl;
}
