#include <bits/stdc++.h>
using namespace std;
long long INFL = 1000000000000000010;
int INF = 2147483600;
int INFM = 100000000;
long long MOD = 1000000007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
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() {
  COMinit();
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<long long> modM(N + 1);
  modM.at(0) = 0;
  for (int i = 1; i <= N; i++) {
    modM.at(i) = modM.at(i - 1) + A.at(i - 1);
    modM.at(i) %= M;
  }
  multiset<long long> set;
  for (int i = 0; i <= N; i++) {
    set.insert(modM.at(i));
  }
  long long res = 0;
  for (int i = 0; i < M; i++) {
    int a = set.count(i);
    res += comb(a, 2);
  }
  cout << res << endl;
}
