#include <bits/stdc++.h>
int main() {
  int n, m, *a;
  bool *check_l;
  long long sum_max = 0, sum, *b;
  std::vector<int> pairs[100001];
  scanf("%d%d", &n, &m);
  a = new int[n];
  check_l = new bool[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    sum_max += a[i];
  }
  for (int i = 0; i < n; i++) check_l[i] = false;
  for (long long i = m; i <= sum_max; i += m) {
    for (int j = 0; j < n; j++) {
      if (!check_l[j]) {
        sum = 0;
        for (int k = j; k < n; k++) {
          sum += a[k];
          if (sum == i) {
            pairs[j].push_back(k);
            check_l[j] = true;
            break;
          } else if (sum > i)
            break;
        }
      }
    }
  }
  delete[] a;
  delete[] check_l;
  b = new long long[n + 1];
  for (int i = 0; i <= n; i++) b[i] = 0;
  sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (pairs[i].size()) {
      for (unsigned int j = 0; j < pairs[i].size(); j++)
        b[i] += b[pairs[i][j] + 1];
      b[i]++;
    }
    sum += b[i];
  }
  printf("%lld\n", sum);
  delete[] b;
  return 0;
}
