#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long N, M;
  long ans = 0;
  cin >> N >> M;
  vector<long> A;
  for (long i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    A.push_back(tmp);
  }
  unordered_set<long> minus;
  minus.insert(0);
  long sum = 0;
  for (auto current : A) {
    sum += current;
    for (long tmp = sum; tmp >= 0; tmp -= M) {
      if (minus.find(tmp) != minus.end()) ans++;
    }
    minus.insert(sum);
  }
  cout << ans << endl;
  return 0;
}
