#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const int mx = 100010;
const long long mod = 1e9 + 7;
vector<long long> inv, fact, invfact;
void mod_build(int n = 101010) {
  fact.resize(n + 1);
  inv.resize(n + 1);
  invfact.resize(n + 1);
  fact[0] = inv[0] = invfact[0] = 1;
  inv[1] = 1;
  for (int i = (int)(0); i < (int)(n); ++i) {
    fact[i + 1] = fact[i] * (i + 1) % mod;
    if (i > 0) inv[i + 1] = mod - inv[mod % (i + 1)] * (mod / (i + 1)) % mod;
    invfact[i + 1] = invfact[i] * inv[i + 1] % mod;
  }
}
long long perm(int n, int k) {
  if (n < 0 || k < 0 || k > n) return 0;
  return fact[n] * invfact[n - k] % mod;
}
long long comb(int n, int k) {
  if (n < 0 || k < 0 || k > n) return 0;
  return (fact[n] * invfact[n - k] % mod) * invfact[k] % mod;
}
long long powmod(long long n, long long k) {
  k %= mod - 1;
  if (k < 0) k += mod - 1;
  long long ret = 1;
  while (k) {
    if (k & 1) ret = ret * n % mod;
    n = n * n % mod;
    k >>= 1;
  }
  return ret;
}
int main() {
  mod_build();
  long long n, m;
  vector<long long> a(mx);
  vector<long long> b(mx, 0);
  cin >> n >> m;
  for (int i = (int)(0); i < (int)(n); ++i) {
    cin >> a[i];
  }
  unordered_map<long long, int> mp;
  for (int i = (int)(0); i < (int)(n); ++i) {
    b[i + 1] = (b[i] + a[i]) % m;
    mp[b[i + 1]]++;
  }
  mp[0]++;
  long long ans = 0;
  for (auto c : mp) {
    ans += comb(c.second, 2);
  }
  cout << ans << endl;
  return 0;
}
