#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e6;
vector<long long> vec;
vector<pair<long long, pair<long long, long long> > > lol;
long long N, K, lim, res, arr[MAX], pre[MAX];
signed main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> K;
  for (long long A = 1; A <= N; A++) {
    cin >> arr[A];
    lim += arr[A];
    pre[A] = pre[A - 1] + arr[A];
  }
  vec.push_back(N + 1);
  for (long long A = N, C = N; A >= 1; A--, C--) {
    if (!(arr[A] % K))
      lol.push_back(make_pair(pre[C - 1] + arr[A] / K, make_pair(A, A)));
    for (long long A = vec.size() - 1, B = arr[C]; A > 0 and B / lim <= K;
         A--) {
      if (B > K * lim) break;
      if (B > (K * lim) / arr[vec[A]]) break;
      B *= arr[vec[A]];
      if (B / lim > K) break;
      if (B > K * lim) break;
      if ((B % K) != 0) continue;
      lol.push_back(
          make_pair(B / K + pre[C - 1], make_pair(vec[A], vec[A - 1] - 1)));
    }
    if (arr[A] > 1) vec.push_back(A);
  }
  long long ptr = 0;
  sort(lol.begin(), lol.end());
  for (long long A = 1; A <= N; A++) {
    while (ptr < lol.size() and lol[ptr].first < pre[A]) ++ptr;
    while (ptr < lol.size() and lol[ptr].first == pre[A]) {
      res += lol[ptr].second.first <= A and lol[ptr].second.second >= A;
      ++ptr;
    }
  }
  cout << res;
  return 0;
}
