#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;
  vector<uint64_t> acc;
  acc.push_back(0);
  for (int i = 0; i < as.size(); ++i) {
    acc.push_back(acc[i] + as[i]);
  }
  map<int, int> modMap = map<int, int>();
  for (int i = 0; i < acc.size(); ++i) {
    modMap.emplace(i, acc[i] % m);
  }
  for (int i = 0; i < as.size(); ++i) {
    for (int j = i; j < as.size(); j++) {
      int l = i;
      int r = j + 1;
      if (modMap[l] == modMap[r]) {
        res++;
      }
    }
  }
  cout << res << endl;
}
