#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll nmax = 100000;
ll d[nmax + 1];
unordered_map<ll, ll> mp;
ll fact(ll n) {
  if (n == 0) return 1;
  return n * fact(n - 1);
}
ll comb(ll n, ll k) { return fact(n) / (fact(k) * fact(n - k)); }
int main() {
  ll N, M, a, ct, sum;
  cin >> N >> M;
  sum = 0;
  for (ll i = 1; i <= N; i++) {
    cin >> a;
    sum += a;
    mp[sum % M]++;
  }
  ll ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    ll a = itr->first;
    ll b = itr->second;
    if (a == 0) {
      if (b > 0) ans += comb(b, 1);
      if (b > 1) ans += comb(b, 2);
    } else if (b > 1) {
      ans += comb(b, 2);
    }
  }
  cout << ans << endl;
  return 0;
}
