#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int main() {
  ll n, m;
  cin >> n >> m;
  ll tempsum = 0;
  vector<ll> mods;
  mods.push_back(0);
  for (int i = 0; i < (n); ++i) {
    ll ai;
    cin >> ai;
    tempsum += ai;
    mods.push_back(tempsum % m);
  }
  map<ll, ll> mp;
  for (int i = 0; i < (mods.size()); ++i) {
    mp[mods[i]] = 0;
  }
  ll ans = 0;
  for (int i = 0; i < (mods.size()); ++i) {
    mp[mods[i]] = mp[mods[i]] + 1;
    int c = mp[mods[i]];
    ans = ans - (c - 1) * (c - 2) / 2 + c * (c - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
