#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::string printVector(const std::vector<T> &data) {
  std::stringstream ss;
  std::ostream_iterator<T> out_it(ss, ", ");
  ss << "[";
  std::copy(data.begin(), data.end() - 1, out_it);
  ss << data.back() << "]";
  return ss.str();
}
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = (0); i < (N); ++i) {
    cin >> A[i];
  }
  map<int, int> mp;
  mp[0] = 1;
  vector<long long> SUM(N + 1);
  SUM[0] = 0;
  for (int i = (1); i < (N + 1); ++i) {
    SUM[i] = (SUM[i - 1] + A[i - 1]) % M;
    cerr << "SUM[i]"
         << " = " << (SUM[i]) << endl;
    mp[SUM[i]]++;
  }
  long long res = 0;
  for (auto m : mp) {
    cerr << "m.first"
         << " = " << (m.first) << endl;
    cerr << "m.second"
         << " = " << (m.second) << endl;
    res += (m.second - 1) * m.second / 2;
  }
  cout << res << endl;
}
