#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const* argv[]) {
  int n, m;
  cin >> n >> m;
  auto as = vector<int>(n);
  for (auto&& a : as) {
    cin >> a;
  }
  uint64_t res = 0;
  uint64_t curr = 0;
  vector<uint64_t> dt;
  for (int i = 0; i < as.size(); ++i) {
    if (dt.size() <= i) {
      curr += as[i];
      dt.push_back(as[i]);
      for (int k = 0; k < i; ++k) {
        dt[k] += dt[i];
      }
    }
  }
  for (int i = 0; i < as.size(); ++i) {
    for (int j = i; j < as.size(); ++j) {
      int l = i;
      int r = j + 1;
      auto curr = dt[l];
      if (r < dt.size()) {
        curr -= dt[r];
      }
      if (curr % m == 0) {
        res++;
      }
    }
  }
  cout << res << endl;
}
