#include <bits/stdc++.h>
using namespace std;
long long INFL = 1000000000000000010;
int INF = 2147483600;
long long MOD = 1000000007;
vector<int> dy = {0, 0, 1, -1};
vector<int> dx = {1, -1, 0, 0};
const int MAXcomb = 200010;
long long fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAXcomb; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * finv[k] % MOD * finv[n - k] % MOD;
}
int main(void) {
  COMinit();
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  vector<long long> wa(N + 1);
  for (int i = 0; i < N; i++) cin >> A[i];
  wa[0] = 0;
  for (int i = 1; i <= N; i++) {
    wa[i] = wa[i - 1] + A[i - 1];
    wa[i] %= M;
  }
  sort(wa.begin(), wa.end());
  wa.push_back(M);
  int cnt = 1;
  long long ans = 0;
  for (int i = 0; i < wa.size(); i++) {
    if (wa[i] != wa[i + 1]) {
      ans += comb(cnt, 2);
      cnt = 1;
    } else {
      cnt++;
    }
  }
  cout << ans << endl;
}
