#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1000000007;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  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 % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (int i = 0; i < (N); ++i) cin >> A[i];
  vector<long long> sum(N);
  sum[0] = A[0] % M;
  for (int i = 1; i <= (N - 1); ++i) {
    sum[i] = sum[i - 1] + A[i];
    sum[i] %= M;
  }
  map<long long, int> m;
  vector<long long> dupl;
  for (int i = 0; i < (N); ++i) {
    if (m[sum[i]] == 1) dupl.push_back(sum[i]);
    m[sum[i]]++;
  }
  long long ans = 0;
  COMinit();
  ans += m[0];
  for (int i = 0; i < (dupl.size()); ++i) {
    long long d = m[dupl[i]];
    ans += COM(d, 2);
  }
  cout << ans << endl;
}
