#include <bits/stdc++.h>
const int MOD = 1000000007, INF = 1111111111;
using namespace std;
class Combi {
 private:
  vector<long long> fac, inv, finv;
  void init(int N) {
    fac[0] = fac[1] = 1;
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for (int i = 2; i < N; 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;
    }
  }

 public:
  Combi(int N = 100000) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }
  long long Cmod(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;
  }
  long long Pmod(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
  }
};
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) A[i] %= M;
  for (int i = 0; i < N - 1; i++) {
    A[i + 1] += A[i];
    A[i + 1] %= M;
  }
  vector<int> mod(M);
  for (int i = 0; i < N; i++) mod[A[i] % M]++;
  Combi C(N + 1);
  long long ans = C.Cmod(mod[0] + 1, 2);
  for (int i = 1; i < M; i++) ans += C.Cmod(mod[i], 2);
  cout << ans << "\n";
  return 0;
}
