#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
inline void print(void) { cout << '\n'; }
template <class T>
inline void print(const T &x) {
  cout << x << '\n';
}
template <class T, class... U>
inline void print(const T &x, const U &...y) {
  cout << x << " ";
  print(y...);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  vector<int> acc(n);
  acc[0] = a[0] % m;
  for (int i = 0; i < (n - 1); ++i) {
    acc[i + 1] = (acc[i] + a[i + 1]) % m;
  }
  map<int, int> b;
  for (int i = 0; i < (n); ++i) ++b[acc[i]];
  long long ans = 0;
  ans += b[0];
  for (auto x : b) {
    ans += x.second * (x.second - 1) / 2;
  }
  print(ans);
  return 0;
}
