#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (const auto &v : vec) {
    os << v << ",";
  }
  os << "]";
  return os;
}
void solve() {
  i64 N, M;
  cin >> N >> M;
  vector<i64> A(N);
  for (i64 i = i64(0), i_max_for_repmacro = i64(N); i < i_max_for_repmacro; ++i)
    cin >> A[i];
  map<i64, i64> cnt;
  i64 acc = A[0];
  ++cnt[A[0] % M];
  for (i64 i = i64(1), i_max_for_repmacro = i64(N); i < i_max_for_repmacro;
       ++i) {
    acc += A[i];
    ++cnt[acc % M];
  }
  i64 ans = 0;
  acc = 0;
  for (i64 i = i64(0), i_max_for_repmacro = i64(N); i < i_max_for_repmacro;
       ++i) {
    ans += cnt[((M - acc) % M + M) % M];
    acc += A[i];
    --cnt[acc % M];
  }
  cout << ans << endl;
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}
