#include <bits/stdc++.h>
using namespace std;
using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;
constexpr double EPS = 1e-10;
template <class T>
inline T sqr(T x) {
  return x * x;
}
void solve() {
  int n, m;
  cin >> n >> m;
  VLL a(n);
  for (int i = int(0); i < int(n); i++) cin >> a[i];
  for (int i = int(0); i < int(n); i++) a[i] %= m;
  VI ru(n);
  ru[0] = a[0];
  for (int i = int(1); i < int(n); i++) ru[i] += (ru[i - 1] + a[i]) % m;
  VI c(m);
  for (int i = int(0); i < int(n); i++) ++c[ru[i]];
  LL sum = 0;
  LL ans = 0;
  for (int i = int(0); i < int(n); i++) {
    ans += c[sum];
    sum = (sum + m + a[i]) % m;
    --c[ru[i]];
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
