#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;
  for (int i = (0); i < (N); ++i) {
    int tmp;
    cin >> tmp;
    A.push_back(tmp);
  }
  long long counter = 0;
  cerr << "A.size()"
       << " = " << (A.size()) << endl;
  for (auto i = 0; i < A.size() - 1; i++) {
    long long acu = 0;
    for (auto j = i; j < A.size(); j++) {
      acu += A[j];
      if (acu % M == 0) counter++;
      cerr << "i"
           << " = " << (i) << endl;
      cerr << "j"
           << " = " << (j) << endl;
    }
  }
  cout << counter << endl;
}
