#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  vector<long long> A, b;
  cin >> N >> M;
  long long s = 0;
  for (int i = 0, a; i < N; ++i) {
    cin >> a;
    A.push_back(a);
    b.push_back(s += a);
  }
  long long c = 0, o = 0;
  for (int l = 0; l < N; ++l) {
    c += count_if(b.begin(), b.end(), [M, o](long long x) {
      x -= o;
      return x > 0 && x % M == 0;
    });
    o += A[l];
  }
  cout << c << endl;
  return 0;
}
