#include <bits/stdc++.h>
template <class T>
bool maxi(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool mini(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int MAX = 100010;
ll fac[MAX], finv[MAX], inv[MAX];
void cinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % 1000000007;
    inv[i] = 1000000007 - inv[1000000007 % i] * (1000000007 / i) % 1000000007;
    finv[i] = finv[i - 1] * inv[i] % 1000000007;
  }
}
ll c(ll n, ll k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % 1000000007) % 1000000007;
}
void Main() {
  ll N, M;
  cin >> N >> M;
  ll A[N], B[N + 1];
  B[0] = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i + 1] = B[i] + A[i];
    B[i + 1] %= M;
  }
  map<ll, ll> ct;
  for (int i = 0; i < N + 1; i++) {
    ++ct[B[i]];
  }
  cinit();
  ll ans = 0;
  for (auto x : ct) {
    ans += c(x.second, 2);
  }
  cout << ans << "\n";
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
