//author Eterna
#define xiongziliang nb
#define songwenqi AK
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<complex>
#include<numeric>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define Pi acos(-1.0)
#define eps 1e-15
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
#define pb(x) push_back(x)
#define lowbit(x) (x & -x)
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\in.txt", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\out.txt", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 2e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
inline int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
inline ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
ll arr[maxn + 5], Next[maxn + 5], sum, product, k, up;
int n, cnt, res;
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i];
		sum += arr[i];
	}
	up = sum * k;
	cnt = -1;
	for (int i = n; i > 0; --i) {
		if (arr[i] == 1 && cnt == -1) {
			Next[i] = i;
			cnt = i;
		}
		else if (arr[i] == 1 && cnt != -1)Next[i] = cnt;
		else cnt = -1;
	}
	for (int i = 1; i <= n; ++i) {
		sum = 0, product = 1;
		for (int j = i; j <= n; ++j) {
			if (arr[j] == 1) {
				if (product % k)sum += (Next[j] - j + 1);
				else {
					ll s = product / k;
					cnt = Next[j] - j + 1;
					if (s - sum > 0 && s - sum <= cnt)++res;
					sum += cnt;
				}
				j = Next[j];
			}
			else {
				product *= arr[j];
				sum += arr[j];
				if (product == sum * k)++res;
			}
			if (product > up)break;
		}
	}
	cout << res << endl;
	return 0;
}


//author Eterna
#define xiongziliang nb
#define songwenqi AK
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<complex>
#include<numeric>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define Pi acos(-1.0)
#define eps 1e-15
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
#define pb(x) push_back(x)
#define lowbit(x) (x & -x)
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\in.txt", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\out.txt", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 2e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
inline int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
inline ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
ll arr[maxn + 5], sum, product, k, up;
int n, cnt, res, Next[maxn + 5];
int main()
{
	n = read_int(), k = read_ll();
	for (int i = 1; i <= n; ++i) {
		arr[i] = read_ll();
		sum += arr[i];
	}
	up = sum * k;
	cnt = -1;
	for (int i = n; i > 0; --i) {
		if (arr[i] == 1 && cnt == -1) {
			Next[i] = i;
			cnt = i;
		}
		else if (arr[i] == 1 && cnt != -1)Next[i] = cnt;
		else cnt = -1;
	}
	for (int i = 1; i <= n; ++i) {
		sum = 0, product = 1;
		for (int j = i; j <= n; ++j) {
			if (arr[j] == 1) {
				if (product % k)sum += (Next[j] - j + 1);
				else {
					ll s = product / k;
					cnt = Next[j] - j + 1;
					if (s - sum > 0 && s - sum <= cnt)++res;
					sum += cnt;
				}
				j = Next[j];
			}
			else {
				if (up / arr[j] < product)break;
				product *= arr[j];
				sum += arr[j];
				if (product == sum * k)++res;
			}
			if (product > up)break;
		}
	}
	cout << res << endl;
	return 0;
}


//author Eterna
#define xiongziliang nb
#define songwenqi AK
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<complex>
#include<numeric>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define Pi acos(-1.0)
#define eps 1e-15
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
#define pb(x) push_back(x)
#define lowbit(x) (x & -x)
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\in.txt", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\out.txt", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 2e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
inline int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
inline ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
ull arr[maxn + 5], sum, product, k, up;
int n, cnt, res, Next[maxn + 5];
int main()
{
	n = read_int(), k = read_ll();
	for (int i = 1; i <= n; ++i) {
		arr[i] = read_ll();
		sum += arr[i];
	}
	up = sum * k;
	cnt = -1;
	for (int i = n; i > 0; --i) {
		if (arr[i] == 1 && cnt == -1) {
			Next[i] = i;
			cnt = i;
		}
		else if (arr[i] == 1 && cnt != -1)Next[i] = cnt;
		else cnt = -1;
	}
	for (int i = 1; i <= n; ++i) {
		sum = 0, product = 1;
		for (int j = i; j <= n; ++j) {
			if (arr[j] == 1) {
				if (product % k)sum += (Next[j] - j + 1);
				else {
					ll s = product / k;
					cnt = Next[j] - j + 1;
					if (s - sum > 0 && s - sum <= cnt)++res;
					sum += cnt;
				}
				j = Next[j];
			}
			else {
				product *= arr[j];
				sum += arr[j];
				if (product == sum * k)++res;
			}
			if (product > up)break;
		}
	}
	cout << res << endl;
	return 0;
}


//author Eterna
#define xiongziliang nb
#define songwenqi AK
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<complex>
#include<numeric>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define Pi acos(-1.0)
#define eps 1e-15
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
#define pb(x) push_back(x)
#define lowbit(x) (x & -x)
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\in.txt", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\out.txt", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 2e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
inline int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
inline ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
ll arr[maxn + 5], cnt[maxn + 5], k, sum, up, x, product;
int n, m, res, tot;
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> x;
		sum += x;
		if (x == 1) {
			if (arr[m] == 1)++cnt[m];
			else {
				arr[++m] = 1;
				cnt[m] = 1;
			}
		}
		else arr[++m] = x;
	}
	up = sum * k;
	for (int i = 1; i <= m; ++i) {
		sum = tot, product = 1;
		for (int j = i; j <= m; ++j) {
			if (arr[j] == 1) {
				if (product % k)sum += cnt[j];
				else {
					ll s = product / k;
					if (s - sum > 0 && (s - sum) <= cnt[j])++res;
					sum += cnt[j];
				}
			}
			else {
				product *= arr[j];
				sum += arr[j];
				if (k * sum == product)++res;
			}
			if (product > up && j + 1 <= m && arr[j + 1] != 1)break;
		}
		if (arr[i] == 1 && tot < cnt[i] - 1) {
			--i;
			++tot;
		}
		else tot = 0;
	}
	cout << res << endl;
	return 0;
}


#include <bits/stdc++.h>
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
*/
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define IOS ios_base::sync_with_stdio(0);

using namespace std;

const ll maxn=2e5+123,inf=1e18,mod=1e9+7,N=360360;
ll n,k,ans,a[maxn];
set<int>st;
int main(){
    #ifdef LOCAL
        freopen ("test.in", "r", stdin);
    #endif
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]!=1)
            st.insert(i);
    }
    a[n+1]=1;
    st.insert(n+1);
    // mult=sum*k
    for(int i=1;i<=n;i++){
        ll len,j=i,q,mult=a[i],sum=a[i];
        while(j<=n){
            q=*st.lower_bound(j+1);
            len=q-j-1;
            if( mult%k==0 && mult>=sum*k && mult<=(sum+len)*k )
                ans++;
            sum+=len+a[q];
            if( sum*k/k==sum && mult*a[q]/a[q]==mult)
                mult*=a[q];
            else
                break;
            j=q;
        }
    }
    cout<<ans;
    #ifdef LOCAL
        cout <<endl<< clock () * 1.0 / CLOCKS_PER_SEC << endl;
    #endif
}


#include <bits/stdc++.h>
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
*/
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define IOS ios_base::sync_with_stdio(0);

using namespace std;

const ll maxn=1e5+123,inf=1e18,mod=1e9+7,N=360360;
ll n,k,ans,a[maxn];
set<int>st;
int main(){
    #ifdef LOCAL
        freopen ("test.in", "r", stdin);
    #endif
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]!=1)
            st.insert(i);
    }
    a[n+1]=1e18;
    st.insert(n+1);
    // mult=sum*k
    for(int i=1;i<=n;i++){
        ll len,j=i,q,mult=a[i],sum=a[i];
        while(j<=n){
            q=*st.lower_bound(j+1);
            len=q-j-1;
           // cout<<i<<" "<<q<<" "<<mult<<" "<<sum<<" "<<len<<endl;
            if( mult>=sum*k && mult<=(sum+len)*k )
                ans++;
            sum+=len+a[q];
            if(mult*a[q]/a[q]==mult)
                mult*=a[q];
            else
                break;
            j=q;
        }
    }
    cout<<ans;
    #ifdef LOCAL
        cout <<endl<< clock () * 1.0 / CLOCKS_PER_SEC << endl;
    #endif
}


#include <bits/stdc++.h>
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
*/
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define IOS ios_base::sync_with_stdio(0);

using namespace std;

const ll maxn=2e5+123,inf=1e18,mod=1e9+7,N=360360;
ll n,k,ans,a[maxn];
set<int>st;
int main(){
    #ifdef LOCAL
        freopen ("test.in", "r", stdin);
    #endif
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]!=1)
            st.insert(i);
    }
    a[n+1]=1e18;
    st.insert(n+1);
    // mult=sum*k
    for(int i=1;i<=n;i++){
        ll len,j=i,q,mult=a[i],sum=a[i];
        while(j<=n){
            q=*st.lower_bound(j+1);
            len=q-j-1;
           // cout<<i<<" "<<q<<" "<<mult<<" "<<sum<<" "<<len<<endl;
            if( mult>=sum*k && mult<=(sum+len)*k )
                ans++;
            sum+=len+a[q];
            if(mult*a[q]/a[q]==mult)
                mult*=a[q];
            else
                break;
            j=q;
        }
    }
    cout<<ans;
    #ifdef LOCAL
        cout <<endl<< clock () * 1.0 / CLOCKS_PER_SEC << endl;
    #endif
}


#include <bits/stdc++.h>
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
*/
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define IOS ios_base::sync_with_stdio(0);

using namespace std;

const ll maxn=2e5+123,inf=1e18,mod=1e9+7,N=360360;
ll n,k,ans,a[maxn];
set<int>st;
int main(){
    #ifdef LOCAL
        freopen ("test.in", "r", stdin);
    #endif
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]!=1)
            st.insert(i);
    }
    a[n+1]=1;
    st.insert(n+1);
    // mult=sum*k
    for(int i=1;i<=n;i++){
        ll len,j=i,q,mult=a[i],sum=a[i];
        while(j<=n){
            q=*st.lower_bound(j+1);
            len=q-j-1;
            if( mult>=sum*k && mult<=(sum+len)*k )
                ans++;
            sum+=len+a[q];
            if( sum*k/k==sum && mult*a[q]/a[q]==mult)
                mult*=a[q];
            else
                break;
            j=q;
        }
    }
    cout<<ans;
    #ifdef LOCAL
        cout <<endl<< clock () * 1.0 / CLOCKS_PER_SEC << endl;
    #endif
}


#include <bits/stdc++.h>
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
*/
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define IOS ios_base::sync_with_stdio(0);

using namespace std;

const ll maxn=2e5+123,inf=1e18,mod=1e9+7,N=360360;
ll n,k,ans,a[maxn];
set<int>st;
int main(){
    #ifdef LOCAL
        freopen ("test.in", "r", stdin);
    #endif
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]!=1)
            st.insert(i);
    }
    st.insert(n+1);
    // mult=sum*k
    for(int i=1;i<=n;i++){
        ll len,j=i,q,mult=a[i],sum=a[i];
        while(j<=n){
            q=*st.lower_bound(j+1);
            len=q-j-1;
           // cout<<i<<" "<<q<<" "<<mult<<" "<<sum<<" "<<len<<endl;
            if( mult>=sum*k && mult<=(sum+len)*k )
                ans++;
            sum+=len+a[q];
            if( sum*k/k==sum && mult*a[q]/a[q]==mult)
                mult*=a[q];
            else
                break;
            j=q;
        }
    }
    cout<<ans;
    #ifdef LOCAL
        cout <<endl<< clock () * 1.0 / CLOCKS_PER_SEC << endl;
    #endif
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int N=5e5;
int n,k,a[N],lst[N];
inline bool chck(ll mul,ll x){
	if(mul>LLONG_MAX/x) return true;
	return false;
}
long long ans=0;
int main(){
	n=read(),k=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		if(a[i-1]==1){
			lst[i]=lst[i-1];
		}else lst[i]=i-1;
	}
	for(int i=1;i<=n;i++){
        ll sum,mul;
        sum=mul=a[i];
		if(k==1){
			ans++;
		}
		for(int head=i,now=lst[head]1;;head=now,now=lst[now]){
			ll res=mul-(ll)sum*k;
			if(res>0&&res%k==0&&res/k<(head-now))ans++;
			if(!now||chck(mul,a[now])) break;
			sum+=a[now]+(head-now-1);
			mul*=a[now];
			if(sum*k==mul) ans++;
		}
	}
	printf("%lld",ans);
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int N=1e6+10;
int n,k,a[N],lst[N];
inline bool chck(ll mul,ll x){
	if(mul>LLONG_MAX/x) return true;
	return false;
}
long long ans=0;
int main(){
	n=read(),k=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		if(a[i-1]==1){
			lst[i]=lst[i-1];
		}else lst[i]=i-1;
	}
	for(int i=1;i<=n;i++){
        ll sum,mul;
        sum=mul=a[i];
		if(k==1){
			ans++;
		}
		for(int head=i,now=lst[head]1;;head=now,now=lst[now]){
			ll res=mul-(ll)sum*k;
			if(res>0&&res%k==0&&res/k<(head-now))ans++;
			if(!now||chck(mul,a[now])) break;
			sum+=a[now]+(head-now-1);
			mul*=a[now];
			if(sum*k==mul) ans++;
		}
	}
	printf("%lld",ans);
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int N=2e5+10;
int n,k,a[N],lst[N];
inline bool chck(ll mul,ll x){
	if(mul>LLONG_MAX/x) return true;
	return false;
}
long long ans=0;
int main(){
	n=read(),k=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		if(a[i-1]==1){
			lst[i]=lst[i-1];
		}else lst[i]=i-1;
	}
	for(int i=1;i<=n;i++){
        ll sum,mul;
        sum=mul=a[i];
		if(k==1){
			ans++;
		}
		for(int head=i,now=lst[head]1;;head=now,now=lst[now]){
			ll res=mul-(ll)sum*k;
			if(res>0&&res%k==0&&res/k<(head-now))ans++;
			if(!now||chck(mul,a[now])) break;
			sum+=a[now]+(head-now-1);
			mul*=a[now];
			if(sum*k==mul) ans++;
		}
	}
	printf("%I64d",ans);
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int N=2e5+10;
int n,k,a[N],lst[N];
inline bool chck(ll mul,ll x){
	if(mul>LLONG_MAX/x) return true;
	return false;
}
long long ans=0;
int main(){
	n=read(),k=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		if(a[i-1]==1){
			lst[i]=lst[i-1];
		}else lst[i]=i-1;
	}
	for(int i=1;i<=n;i++){
        ll sum,mul;
        sum=mul=a[i];
		if(k==1){
			ans++;
		}
		for(int head=i,now=lst[head];;head=now,now=lst[now]){
			ll res=mul-(ll)sum*k;
			if(res>0&&res%k==0&&res/k<(head-now))ans++;
			if(!now||chck(mul,a[now])) break;
			sum+=a[now]+(head-now-1);
			mul*=a[now];
			if(sum*k==mul) ans++;
		}
	}
	printf("%lld",ans);
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int N=5e5;
int n,k,a[N],lst[N];
inline bool chck(ll mul,ll x){
	if(mul>LLONG_MAX/x) return true;
	return false;
}
long long ans=0;
int main(){
	n=read(),k=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		if(a[i-1]==1){
			lst[i]=lst[i-1];
		}else lst[i]=i-1;
	}
	for(int i=1;i<=n;i++){
        ll sum,mul;
        sum=mul=a[i];
		if(k==1){
			ans++;
		}
		for(int head=i,now=lst[head]1;;head=now,now=lst[now]){
			ll res=mul-(ll)sum*k;
			if(res>0&&res%k==0&&res/k<(head-now))ans++;
			if(!now||chck(mul,a[now])) break;
			sum+=a[now]+(head-now-1);
			mul*=a[now];
			if(sum*k==mul) ans++;
		}
	}

	printf("%lld",ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define N 200001

int a[N];
ll S[N];

bool IsValid(ll p, ll s, int x){
  ll d = p - s;
  return (d >= 1 && d <= x);
}

int main(){
  int n, k;
  set<int> B;
  ll ans = 0;

  scanf("%d%d", &n, &k);

  for(int i = 1; i <= n; ++i){
    scanf("%d", &a[i]);
    S[i] = S[i - 1] + a[i];
    if(a[i] > 1){
      B.insert(i);
    }
  }

  B.insert(n + 1);

  for(int i = 1; i <= n; ++i){
    int kx = k;
    ll sMax = S[n] - S[i - 1], p = 1;
    B.insert(i);
    for(auto it = B.begin(); it != B.end() && *it <= n; ++it){
      int j = *it;
      int x = a[j], g = __gcd(x, kx);

      kx /= g, x /= g;

      if(sMax / x < p){
        break;
      }

      p *= x;
      ll s = S[j] - S[i - 1];

      if(kx == 1 && s == p){
        ++ans;
      }

      auto jt = it;
      ++jt;
      ans += IsValid(p, s, *jt - *it - 1);
    }
    B.erase(i);
  }

  printf("%lld\n", ans);

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define N 200001

int a[N];
ll S[N];

bool ShouldStop(vector<int>& v, ll s){
  s = 3E18;
  for(auto x : v)
    s /= x;
  return (s == 0);
}

bool IsValid(ll p, ll s, int x){
  ll d = p - s;
  return (d >= 1 && d <= x);
}

int main(){
  int n, k;
  set<int> B;
  ll ans = 0;

  scanf("%d%d", &n, &k);

  for(int i = 1; i <= n; ++i){
    scanf("%d", &a[i]);
    S[i] = S[i - 1] + a[i];
    if(a[i] > 1){
      B.insert(i);
    }
  }

  B.insert(n + 1);

  for(int i = 1; i <= n; ++i){
    int kx = k;
    ll sMax = S[n] - S[i - 1], p = 1;
    vector<int> v;

    B.insert(i);

    for(auto it = B.begin(); *it <= n; ++it){
      int j = *it;
      int x = a[j], g = __gcd(x, kx);

      kx /= g, x /= g;

      if(x > 1){
        v.PB(x);
      }

      if(ShouldStop(v, sMax)){
        break;
      }

      p *= x;
      ll s = S[j] - S[i - 1];

      if(kx == 1 && s == p){
        ++ans;
      }

      auto jt = it;
      ++jt;
      ans += IsValid(p, s, *jt - *it - 1);
    }

    B.erase(i);
  }

  printf("%lld\n", ans);

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define N 200001

int a[N];
ll S[N];

bool ShouldStop(vector<int>& v, ll s){
  for(auto x : v)
    s /= x;
  return (s == 0);
}

bool IsValid(ll p, ll s, int x){
  ll d = p - s;
  return (x > 0 && d > 0 && d <= x);
}

int main(){
  int n, k;
  set<int> B;
  ll ans = 0;

  scanf("%d%d", &n, &k);

  for(int i = 1; i <= n; ++i){
    scanf("%d", &a[i]);
    S[i] = S[i - 1] + a[i];
    if(a[i] > 1){
      B.insert(i);
    }
  }

  B.insert(n + 1);

  for(int i = 1; i <= n; ++i){
    int kx = k;
    ll sMax = S[n] - S[i - 1], p = 1;
    vector<int> v;

    B.insert(i);

    for(auto it = B.begin(); *it <= n; ++it){
      int j = *it;
      int x = a[j], g = __gcd(x, kx);

      kx /= g, x /= g;

      if(x > 1){
        v.PB(x);
      }

      if(ShouldStop(v, sMax)){
        break;
      }

      p *= x;
      ll s = S[j] - S[i - 1];

      if(kx == 1){
        ans += (s == p);
        ans += IsValid(p, s, *B.upper_bound(j) - j - 1);
      }
    }

    B.erase(i);
  }

  printf("%lld\n", ans);

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define N 200001

int a[N];
ll S[N];

bool ShouldStop(vector<int>& v, ll s){
  for(auto x : v)
    s /= x;
  return (s == 0);
}

bool IsValid(ll p, ll s, int x){
  ll d = p - s;
  return (x > 0 && d > 0 && d <= x);
}

int main(){
  int n, k;
  set<int> B;
  ll ans = 0;

  scanf("%d%d", &n, &k);

  for(int i = 1; i <= n; ++i){
    scanf("%d", &a[i]);
    S[i] = S[i - 1] + a[i];
    if(a[i] > 1){
      B.insert(i);
    }
  }

  B.insert(n + 1);

  for(int i = 1; i <= n; ++i){
    int kx = k;
    ll sMax = S[n] - S[i - 1], p = 1;
    vector<int> v;

    B.insert(i);

    for(auto it = B.begin(); *it <= n; ++it){
      int j = *it;
      int x = a[j], g = __gcd(x, kx);

      kx /= g, x /= g;

      if(x > 1){
        v.PB(x);
      }

      if(ShouldStop(v, sMax)){
        break;
      }

      p *= x;
      ll s = S[j] - S[i - 1];

      if(kx == 1 && s == p){
        ++ans;
      }

      ans += IsValid(p, s, *B.upper_bound(j) - j - 1);
    }

    B.erase(i);
  }

  printf("%lld\n", ans);

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define N 200001

int a[N];
ll S[N];

bool ShouldStop(vector<int>& v, ll s){
  for(auto x : v)
    s /= x;
  return (s == 0);
}

bool IsValid(ll p, ll s, int x){
  ll d = p - s;
  return (d >= 1 && d <= x);
}

int main(){
  int n, k;
  set<int> B;
  ll ans = 0;

  scanf("%d%d", &n, &k);

  for(int i = 1; i <= n; ++i){
    scanf("%d", &a[i]);
    S[i] = S[i - 1] + a[i];
    if(a[i] > 1){
      B.insert(i);
    }
  }

  B.insert(n + 1);

  for(int i = 1; i <= n; ++i){
    int kx = k;
    ll sMax = S[n] - S[i - 1], p = 1;
    vector<int> v;

    B.insert(i);

    for(auto it = B.begin(); it != B.end() && *it <= n; ++it){
      int j = *it;
      int x = a[j], g = __gcd(x, kx);

      kx /= g, x /= g;

      if(x > 1){
        v.PB(x);
      }

      if(ShouldStop(v, sMax)){
        break;
      }

      p *= x;
      ll s = S[j] - S[i - 1];

      if(kx == 1 && s == p){
        ++ans;
      }

      auto jt = it;
      ++jt;
      ans += IsValid(p, s, *jt - *it - 1);
    }
    B.erase(i);
  }

  printf("%lld\n", ans);

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define N 200001

int a[N];
ll S[N];

int main(){
  int n, k;
  set<int> B;
  ll ans = 0;

  scanf("%d%d", &n, &k);

  for(int i = 1; i <= n; ++i){
    scanf("%d", &a[i]);
    S[i] = S[i - 1] + a[i];
    if(a[i] > 1){
      B.insert(i);
    }
  }

  B.insert(n + 1);

  for(int i = 1; i <= n; ++i){
    int kx = k;
    ll sMax = S[n] - S[i - 1], p = 1;

    B.insert(i);

    for(auto it = B.begin(); it != B.end() && *it <= n; ++it){
      int j = *it;
      int x = a[j], g = __gcd(x, kx);

      kx /= g, x /= g;

      if(sMax / x < p){
        break;
      }

      p *= x;
      ll s = S[j] - S[i - 1];

      if(kx == 1){
        ans += ((p == s) || (p > s && (p - s <= *B.upper_bound(j) - j - 1)));
      }
    }

    B.erase(i);
  }

  printf("%lld\n", ans);

  return 0;
}


#include<cstdio>
using namespace std;
const int N=2e5+5;
typedef long long ll;
const ll inf=(ll)1e19;
int n,k,a[N],las[N];
inline void init(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		las[i]=(a[i-1]!=1)?i-1:las[i-1];
	}
}
ll ans;
inline void solve(){
	for (int i=1;i<=n;i++){
		ll sum,mul; sum=mul=a[i];
		ans+=(k==1);
		for (ll pre=i,now=las[i];;pre=now,now=las[now]){
			ll tmp=mul-sum*(ll)k;
			if (tmp>0&&tmp%k==0&&tmp/k<pre-now) ans++;
			if (!now||inf/a[now]<mul) break;
			mul*=(ll)a[now],sum+=(ll)a[now]+pre-now-1;
			ans+=(mul==sum*(ll)k);
		}
	}
	printf("%I64d\n",ans);
}
int main(){
	init();
	solve();
	return 0;
}


#include <cstdio>
#define int long long
const long long  MLL = 9223372036854775807;

using namespace std;

int N,K,a[201000],lr[201000],ans,del_M,del_N;

signed main()
{
    scanf("%lld%lld",&N,&K);
    for(int i = 1 ; i <= N ; i ++ )scanf("%lld",&a[i]),lr[i] = (a[i - 1] == 1 ? lr[i - 1]:i - 1);
    for(int i = 1 ; i <= N ; i ++ )
    {
        int mul = a[i],sum = a[i];
        for(int l = lr[i] ,r = i ; ; r = l , l = lr[l])
        {
            del_M = mul - K*sum;del_N = r - l - 1;
            if(del_M > 0 && del_M % K == 0 && del_N *K >= del_M )ans ++;
            if(MLL/(sum + del_N)< mul || l == 0 )break;
            sum += a[l] + del_N;
            mul *= a[l];
            if(1.*sum == 1.*mul/K)ans++;
        }
    }
    printf("%lld",ans + (K == 1?N:0));
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int sum1,sum2;
const int N = 1e5;
int a[N];
int ans;
ll n,m;
void scan()
{
    cin>>n>>m;
    for(ll i=1;i<=n;i++)
    scanf("%lld",&a[i]);
}

int main(){
	scan();
	for ( int i=0;i<n;i++)
		{
			sum1+=a[i];
			sum2*=a[i];
			if(sum1*m==sum2) ans++;
		}
	cout<<ans;
	return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#define MAX 1<<25
#define INF 2333330303.3
#define rg register
#define abs(a) ((a)>0?(a):-(a))
#define ll long long
using namespace std;
const int maxn=450000;
namespace io
{
    static char B[1<<24],*S=B;
    inline void in()
    {
        fread(B,1,1<<24,stdin);
    }
    inline ll read()
    {
        rg bool bo=0;
        for(;*S<'-';S++);
        rg ll x=*S++-'0';
        for(;*S>='0';x=(x<<3)+(x<<1)+*S++-'0');
        return bo?-x:x;
    }
    static char Buf[1<<26],*O=Buf,Stk[20];
    inline void write(rg ll x)
    {
        rg ll Ts=0;
        if(x==0)
            *O++='0';
        for(;x;)
            Stk[++Ts]=x%10,x/=10;
        for(;Ts;)
            *O++='0'+Stk[Ts--];
        *O++='\n';
    }
    inline void out()
    {
        fwrite(Buf,1,O-Buf,stdout),O=Buf;
    }
}
using namespace io;
inline ll max(ll a,ll b)
{
    if(a>b) return a;
    return b;
}
inline ll min(ll a,ll b)
{
    if(a>b) return b;
    return a;
}
ll a[maxn],s[maxn];
int n,k;
ll Left[maxn];
ll x,tag,tot;
int main()
{
	in();
    n=read();
    k=read();
    for(rg int i=1;i<=n;++i)
    {
        a[i]=read();
        s[i]=s[i-1]+a[i];
    }
    //求出所有点左边第一个不为1的数的位置
    for(rg int i=1;i<=n;++i)
    {
        if(a[i-1]!=1)
        {
            Left[i]=i-1;
        }
        else
        {
            Left[i]=Left[i-1];
        }
    }
    for(rg int i=1;i<=n;++i)
    {
        ll sum1=a[i];
        ll sum2=a[i];
        if(sum2==sum1*k)
        {
            ++tot;
        }
        for(rg int j=i,now=Left[i];;now=Left[now],j=Left[j])
        {
            ll res=sum2-sum1*k;
            if(res>0&&res%k==0&&res/k<j-now)//当res,且整除k，并且除K后的值小于连续一段1
            {
                tot++;//此时一定能在这连续的1中找到一个值满足sum2/sum1=k
            }
            if(now==0||res>MAX)//左边全是1了 或者乘积已经过大了,就完全没必要继续下去了
            {
                break;
            }
            sum1+=s[j-1]-s[Left[j]-1];
            sum2*=a[Left[j]];
            if(sum2==sum1*k)
            {
                ++tot;
            }
        }
    }
	write(tot);
	out();
}


#include<cstdio>
using namespace std;
const int N=2e5+5;
typedef long long ll;
const ll inf=(ll)1e19;
int n,k,a[N],las[N];
inline void init(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		las[i]=(a[i-1]!=1)?i-1:las[i-1];
	}
}
ll ans;
inline void solve(){
	for (int i=1;i<=n;i++){
		ll sum,mul; sum=mul=a[i];
		ans+=(k==1);
		for (ll pre=i,now=las[i];;pre=now,now=las[now]){
			ll tmp=mul-sum*(ll)k;
			if (tmp>0&&tmp&k==0&&tmp/k<pre-now) ans++;
			if (!now||inf/a[now]<mul) break;
			mul*=(ll)a[now],sum+=(ll)a[now]+pre-now-1;
			ans+=(mul==sum*(ll)k);
		}
	}
	printf("%I64d\n",ans);
}
int main(){
	init();
	solve();
	return 0;
}


#include <cstdio>
#define int long long
const long long  MLL = 9223372036854775807;

using namespace std;

int N,K,a[201000],lr[201000],ans;

signed main()
{
	scanf("%lld%lld",&N,&K);
	for(int i = 1 ; i <= N ; i ++ )scanf("%lld",&a[i]),lr[i] = (a[i - 1] == 1 ? lr[i - 1]:i - 1);
	for(int i = 1 ; i <= N ; i ++ )
	{
		int mul = a[i],sum = a[i];
		for(int l = lr[i] ,r = i ; ; r = l , l = lr[l])
		{
			int del_M = mul - K*sum;
			int del_N = r - l - 1;
			if(del_M > 0 && del_M % K == 0 && del_N *K >= del_M )ans ++;
			if(MLL/(sum + del_N)< mul || l == 0 )break;
			sum += a[l] + del_N;
			mul *= a[l];
			if(1.*sum == 1.*mul/K)ans++;
		}
	}
	printf("%lld",ans + (K == 1?N:0));
	return 0;
}


#include <cstdio>
#define int long long
const long long  MLL = 9223372036854775807;

using namespace std;

int N,K,a[201000],lr[201000],ans,del_M,del_N;

signed main()
{
    scanf("%lld%lld",&N,&K);
    for(int i = 1 ; i <= N ; ++ i )scanf("%lld",&a[i]),lr[i] = a[i - 1] == 1 ? lr[i - 1]:i - 1;
    for(int i = 1 ; i <= N ; ++ i )
    {
        int mul = a[i],sum = a[i];
        ans+=K==1;
        for(int l = lr[i] ,r = i ; ; r = l , l = lr[l])
        {
            del_M = mul - K*sum;;
            if(del_M > 0 && del_M % K == 0 && (r - l - 1) *K >= del_M )ans ++;
            if(MLL/sum < mul || l == 0 )break;
            sum += a[l] + (r - l - 1 );mul *= a[l];
            ans+= K*sum == mul;
        }
    }
    printf("%lld",ans );
    return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#define MAX 2000000000
#define INF 2333330303.3
#define rg register
#define abs(a) ((a)>0?(a):-(a))
#define ll long long
using namespace std;
const int maxn=1050000;
namespace io
{
    static char B[1<<24],*S=B;
    inline void in()
    {
        fread(B,1,1<<24,stdin);
    }
    inline ll read()
    {
        rg bool bo=0;
        for(;*S<'-';S++);
        rg ll x=*S++-'0';
        for(;*S>='0';x=(x<<3)+(x<<1)+*S++-'0');
        return bo?-x:x;
    }
    static char Buf[1<<26],*O=Buf,Stk[20];
    inline void write(rg ll x)
    {
        rg ll Ts=0;
        if(x==0)
            *O++='0';
        for(;x;)
            Stk[++Ts]=x%10,x/=10;
        for(;Ts;)
            *O++='0'+Stk[Ts--];
        *O++='\n';
    }
    inline void out()
    {
        fwrite(Buf,1,O-Buf,stdout),O=Buf;
    }
}
using namespace io;
inline ll max(ll a,ll b)
{
    if(a>b) return a;
    return b;
}
inline ll min(ll a,ll b)
{
    if(a>b) return b;
    return a;
}
ll a[maxn],s[maxn];
int n,k;
ll Left[maxn];
ll x,tag,tot;
int main()
{
	in();
	n=read();
	k=read();
	for(rg int i=1;i<=n;++i)
	{
		a[i]=read();
		s[i]=s[i-1]+a[i];
	}
	//求出所有点左边第一个不为1的数的位置
	for(rg int i=1;i<=n;++i)
	{
		if(a[i-1]!=1)
		{
			Left[i]=i-1;
		}
		else
		{
			Left[i]=Left[i-1];
		}
	}
	for(rg int i=1;i<=n;++i)
	{
		ll sum1=a[i];
		ll sum2=a[i];
		if(sum2==sum1*k)
		{
			++tot;
		}
		for(rg int j=i;j>=1;j=Left[j])
		{
			ll res=sum2-sum1*k;
			if(res>0&&res%k==0&&res/k<j-Left[j])//当res,且整除k，并且除K后的值小于连续一段1
			{
				tot++;//此时一定能在这连续的1中找到一个值满足sum2/sum1=k
			}
			if(Left[j]==0||res/k>j-Left[j])//左边全是1了 或者连续的1不够大
			{
				break;
			}
			sum1+=s[j-1]-s[Left[j]-1];
			sum2*=a[Left[j]];
			if(sum2==sum1*k)
			{
				++tot;
			}
		}
	}
	write(tot);
	out();
}


#include<bits/stdc++.h>
using namespace std;

const int maxn=2e5;
const long long inf=(long long)1e19;
int n,k;
int a[maxn],lef[maxn];
long long mul,sum,ans,w;

inline int read(){
    int x=0; char ch=getchar();
    for(;!isdigit(ch);ch=getchar());
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
    return x;
}

void solve(){
	const int num=k;
	for(int i=1;i<=n;i++){
		sum=mul=a[i],ans+=(k==1);
		for(int p=i,now=lef[i];;p=now,now=lef[now]){
			w=mul-sum*(unsigned long long)k;
			if(w>0&&w%num==0&&w/num<p-now) ans++;
			if(!now||inf/a[now]<mul) break;
			mul*=(long long)a[now],sum+=(long long)a[now]+p-now-1;
			ans+=(mul==sum*(long long)k);
		}
	}
}

int main()
{
	n=read();k=read();
	for(int i=1;i<=n;i++) a[i]=read(),lef[i]=(a[i-1]!=1?i-1:lef[i-1]);
	solve();
	printf("%lld",ans);
	return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#define MAX 2000000000
#define INF 2333330303.3
#define rg register
#define abs(a) ((a)>0?(a):-(a))
#define ll long long
using namespace std;
const int maxn=450000;
inline int read()
{
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
inline void print(int x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>=10)
    {
        print(x/10);
    }
    putchar(x%10+'0');
}
//namespace io
//{
//    static char B[1<<24],*S=B;
//    inline void in()
//    {
//        fread(B,1,1<<24,stdin);
//    }
//    inline ll read()
//    {
//        rg bool bo=0;
//        for(;*S<'-';S++);
//        rg ll x=*S++-'0';
//        for(;*S>='0';x=(x<<3)+(x<<1)+*S++-'0');
//        return bo?-x:x;
//    }
//    static char Buf[1<<26],*O=Buf,Stk[20];
//    inline void write(rg ll x)
//    {
//        rg ll Ts=0;
//        if(x==0)
//            *O++='0';
//        for(;x;)
//            Stk[++Ts]=x%10,x/=10;
//        for(;Ts;)
//            *O++='0'+Stk[Ts--];
//        *O++='\n';
//    }
//    inline void out()
//    {
//        fwrite(Buf,1,O-Buf,stdout),O=Buf;
//    }
//}
//using namespace io;
inline ll max(ll a,ll b)
{
    if(a>b) return a;
    return b;
}
inline ll min(ll a,ll b)
{
    if(a>b) return b;
    return a;
}
ll a[maxn],s[maxn];
int n,k;
ll Left[maxn];
ll x,tag,tot;
inline bool Overflow(ll mul,ll x)
{
    if(mul>LLONG_MAX/x) return true;
    return false;
}
int main()
{
//	in();
	n=read();
	k=read();
	for(rg int i=1;i<=n;++i)
	{
		a[i]=read();
		s[i]=s[i-1]+a[i];
	}
	//求出所有点左边第一个不为1的数的位置
	for(rg int i=1;i<=n;++i)
	{
		if(a[i-1]!=1)
		{
			Left[i]=i-1;
		}
		else
		{
			Left[i]=Left[i-1];
		}
	}
	for(rg int i=1;i<=n;++i)
	{
		ll sum1=a[i];
		ll sum2=a[i];
		if(sum2==sum1*k)
		{
			++tot;
		}
		for(rg int j=i,now=Left[i];;now=Left[now],j=Left[j])
		{
			ll res=sum2-sum1*k;
			if(res>0&&res%k==0&&res/k<j-now)//当res,且整除k，并且除K后的值小于连续一段1
			{
				tot++;//此时一定能在这连续的1中找到一个值满足sum2/sum1=k
			}
			if(now==0||Overflow(res,a[now]))//左边全是1了 或者连续的1不够大
			{
				break;
			}
			sum1+=s[j-1]-s[Left[j]-1];
			sum2*=a[Left[j]];
			if(sum2==sum1*k)
			{
				++tot;
			}
		}
	}
	cout<<tot;
//	write(tot);
//	out();
}


#include <iostream>
using namespace std;
#define re register int
#define rep(i,a,b) for(re i=(a);i<=(b);++i)
#define drep(i,a,b) for(re i=(a);i>=(b);--i)
int n, k, a[200020], ans=0;

int main() {
	ios::sync_with_stdio(0);
	cin >> n >> k;
	rep(i,1,n)	cin >> a[i];
	long long now, kkk; int sum;
	rep(i,1,n) {
		kkk=now=1, sum=0;
		rep(z,i,n) {
			now*=a[z], sum+=a[z];
			if(now<kkk)	break;
			if(now==sum*k)	++ans;
			kkk = now;
		}
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
using namespace std;
#define re register int
#define rep(i,a,b) for(re i=(a);i<=(b);++i)
#define drep(i,a,b) for(re i=(a);i>=(b);--i)
int n, k, a[200020], ans=0;

int main() {
	ios::sync_with_stdio(0);
	cin >> n >> k;
	rep(i,1,n)	cin >> a[i];
	long long now; int sum;
	rep(i,1,n) {
		now=1, sum=0;
		rep(z,i,n) {
			now*=a[z], sum+=a[z];
			if(now < 0)	break;
			if(now==sum*k)	++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
using namespace std;
#define re register int
#define rep(i,a,b) for(re i=(a);i<=(b);++i)
#define drep(i,a,b) for(re i=(a);i>=(b);--i)
int n, k, a[200020], ans=0;

int main() {
	ios::sync_with_stdio(0);
	cin >> n >> k;
	rep(i,1,n)	cin >> a[i];
	long long now; int sum;
	rep(i,1,n) {
		now=1, sum=0;
		rep(z,i,n) {
			now*=z, sum+=z;
			if(now < 0)	break;
			if(now/sum==k)	++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <climits>
using namespace std;
#define re register int
#define rep(i,a,b) for(re i=(a);i<=(b);++i)
#define drep(i,a,b) for(re i=(a);i>=(b);--i)
typedef long long ll;
int n, k, a[200020], jump[200020], ans=0;
inline bool overflow_LL(ll a, ll b) { return a>LLONG_MAX/b;}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	rep(i,1,n)	cin >> a[i];
	jump[n] = n+1;
	drep(i,n-1,1)
		jump[i]=(a[i+1]==1&&a[i]==1)?jump[i+1]:i+1;

	long long now, sum;
	rep(i,1,n) {
		now=1, sum=0;
		for(re j=i;j<=n;j=jump[j]) {
			if(a[j]==1) {
				if(now%k==0 && sum*k<now && (sum+jump[j]-j)*k>=now)	++ans;
				sum += jump[j]-j;
			}
			else {
				if(overflow_LL(now, a[j]))	break;
				now*=a[j], sum+=a[j];
				if(now==sum*k)	++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <climits>
using namespace std;
#define re register int
#define rep(i,a,b) for(re i=(a);i<=(b);++i)
#define drep(i,a,b) for(re i=(a);i>=(b);--i)
typedef long long ll;
int n, k, a[200020], jump[200020], ans=0;
inline bool overflow_LL(ll a, ll b) { return a>LLONG_MAX/b;}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	rep(i,1,n)	cin >> a[i];
	jump[n] = n+1;
	drep(i,n-1,1)
		jump[i]=(a[i+1]==1&&a[i]==1)?jump[i+1]:i+1;
	long long now, sum;
	rep(i,1,n) {
		now=1, sum=0;
		for(re j=i;j<=n;j=jump[j]) {
			if(a[j]==1) {
				if(now%k==0 && sum*k<now && (sum+jump[j]-j)*k>=now)	++ans;
				sum += jump[j]-j;
			}
			else {
				if(overflow_LL(now, a[j]))	break;
				now*=a[j], sum+=a[j];
				if(now==sum*k)	++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


#include<cstdio>
using namespace std;
using LL=long long;

int n,m,k,a[200005],b[200005],pos[200005];
LL cnt;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if(k==1)
	{
		printf("%lld",(LL)n);
		return 0;
	}
	for(int i=1;i<=n;i++)
		if(a[i]>1)
			b[++m]=a[i],pos[m]=i;
	pos[m+1]=n+1;
	for(int i=1;i<=m;i++)
	{
		LL mul=1,sum=0,zn;
		for(int j=i;j<=m&&mul<=2E18/b[j];j++)
		{
			mul*=b[j];
			sum+=b[j];
			if(mul%k==0&&mul/sum>=k)
			{
				zn=mul/k-sum;
				if(zn>=pos[j]-pos[i]-j+i&&zn<=pos[j+1]-pos[i]-j-1+i)
					cnt++;
			}
		}
	}
	printf("%lld",cnt);
	return 0;
}


#include<cstdio>
using namespace std;
using LL=long long;

int n,m,k,a[200005],b[200005],pos[200005];
LL cnt;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if(k==1)
	{
		printf("%lld",n);
		return 0;
	}
	for(int i=1;i<=n;i++)
		if(a[i]>1)
			b[++m]=a[i],pos[m]=i;
	pos[m+1]=n+1;
	for(int i=1;i<=m;i++)
	{
		LL mul=1,sum=0,zn;
		for(int j=i;j<=m&&mul<=2E18/b[j];j++)
		{
			mul*=b[j];
			sum+=b[j];
			if(mul%k==0&&mul/sum>=k)
			{
				zn=mul/k-sum;
				if(zn>=pos[j]-pos[i]-j+i&&zn<=pos[j+1]-pos[i]-j-1+i)
					cnt++;
			}
		}
	}
	printf("%lld",cnt);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
using LL=long long;

int n,m,k,a[200005],b[200005],pos[200005];
LL ans;

void solve()
{
	pos[m+1]=n+1;
	for(int i=1;i<=m;i++)
	{
		LL mul=1,sum=0,zn;
		for(int j=i;j<=m&&mul<=2E18/b[j];j++)
		{
			mul*=b[j];
			sum+=b[j];
			if(mul%k==0&&mul/sum>=k)
			{
				zn=mul/k-sum;
				if(zn>=pos[j]-pos[i]-j+i&&zn<=pos[j+1]-pos[i-1]-j+i-2)
					ans+=min(min((int)(zn)-(pos[j]-pos[i]-j+i)+1,(pos[j+1]-pos[i-1]-j+i-2)-(int)(zn)+1),min(pos[i]-pos[i-1],pos[j+1]-pos[j]));
			}
		}
	}
}

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		if(a[i]>1)
			b[++m]=a[i],pos[m]=i;
	if(k==1)
		ans+=n-m;
	solve();
	printf("%lld",ans);
	return 0;
}


#include<cstdio>
using namespace std;
using LL=long long;

int n,m,k,a[200005],cnt,b[200005],pos[200005];

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		if(a[i]>1)
			b[++m]=a[i],pos[m]=i;
	pos[m+1]=n+1;
	for(int i=1;i<=m;i++)
	{
		LL mul=1,sum=0,zn;
		for(int j=i;j<=m&&mul<=2E18/b[j];j++)
		{
			mul*=b[j];
			sum+=b[j];
			if(mul%k==0&&mul/sum>=k)
			{
				zn=mul/k-sum;
				if(zn>=pos[j]-pos[i]-j+i&&zn<=pos[j+1]-pos[i]-j-1+i)
					cnt++;
			}
		}
	}
	printf("%d",cnt);
	return 0;
}


#include <iostream>
#define LG 100
#define NMAX 200000

using namespace std;

int n, k, sol;
long long v[NMAX+10], one[NMAX+10];

int main()
{
    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> v[i];
    for(int i=n; i; i--)
        if(v[i+1] == 1) one[i] = one[i+1] + 1;
    for(int i=1; i<=max(n, n-LG); i++)
        {   long long p = 1, s = 0;
            for(int j=i; j<=min(n, i+LG); j++)
                {   s += v[j];
                    p *= v[j];
                    if(p == s * k) sol++;
                }
            if(p > s*k && p-s*k <= one[min(n, i+LG)]) sol++;
        }
    cout << sol << '\n';
    return 0;
}


#include <iostream>
#define LG 100
#define NMAX 200000

using namespace std;

int n, k, sol;
long long v[NMAX+10], one1[NMAX+10], one2[NMAX+10];

int main()
{
    cin >> n >> k;
    for(int i=1; i<=n; i++)
        {   cin >> v[i];
            if(v[i] == 1) one1[i] = one1[i-1] + 1;
        }
    for(int i=n; i; i--)
        if(v[i+1] == 1) one2[i] = one2[i+1] + 1;

    for(int i=1; i<=max(n, n-LG); i++)
        {   long long p = 1, s = 0;
            for(int j=i; j<=min(n, i+LG); j++)
                {   s += v[j];
                    p *= v[j];
                    if(p == s * k) sol++;
                }
            if(p > s*k && p-s*k <= one1[i] + one2[min(n, i+LG)]) sol++;
        }
    cout << sol << '\n';
    return 0;
}


#include <iostream>
#define LG 60
#define NMAX 200000

using namespace std;

int n, k, sol;
long long v[NMAX+10], one[NMAX+10];

int main()
{
    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> v[i];
    for(int i=n; i; i--)
        if(v[i+1] == 1) one[i] = one[i+1] + 1;
    for(int i=1; i<=max(n, n-LG); i++)
        {   long long p = 1, s = 0;
            for(int j=i; j<=min(n, i+LG); j++)
                {   s += v[j];
                    p *= v[j];
                    if(p == s * k) sol++;
                }
            //cout << one[min(n, i+LG)] << '\n';
            if(p > s*k && p-s*k <= one[min(n, i+LG)]) sol++;
        }
    cout << sol << '\n';
    return 0;
}


#include <iostream>
#define NMAX 200000
#define LG 65

using namespace std;

long long n, k, v[NMAX+10], nxt[NMAX+10], sol;

int main()
{
    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> v[i];
    int i = 1;
    while(i <= n)
        {   int j = i+1;
            while(v[j] == 1) j++;
            for(int k=i; k<j; k++) nxt[k] = j;
            i = j;
        }
    for(int i=1; i<=nxt[i]; i++)
        {   int j = i, nr = 0, ok = 1;
            long long p = 1, s = 0;
            while(ok)
                {   nr++;
                    p = p * v[j];
                    s += v[j];
                    long long s1 = s, s2 = s + nxt[j] - j - 1;
                    if(p % k == 0 && p/k >= s1 && p/k <= s2) sol++;
                    s = s2;
                    j = nxt[j];
                    if(j > n || nr > LG || p/k > (s+n-j)) ok = 0;
                }
        }
    cout << sol << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int MX=200010;
const ll inf=3e18;

int A[MX], n, k;
ll S[MX], ans;

bool valid(ll a, ll b){
    return a<=inf/b;
}

int nxt[MX];

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for(int i=1; i<=n; i++){
        cin>>A[i]; S[i]=S[i-1]+A[i];
    }
    nxt[n]=n+1;
    for(int i=n-1; i>=1; i--)
        nxt[i]=(A[i+1]==1 ? nxt[i+1] : i+1);

    for(int l=1; l<=n; l++){
        ll p=1;
        for(int r=l; r<=n; r=nxt[r]){
            if(!valid(p,A[r])) break;
            p*=A[r];
            ll sum=S[r]-S[l-1]; int cnt=nxt[r]-r-1;
            ans+=(p%k==0 && k*sum<=p && p<=k*(sum+cnt)) ? 1 : 0;
        }
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int MX=200010;
const ll inf=3e18;

int A[MX], n, k;
ll S[MX], ans;

bool valid(ll a, ll b){
    return a<=inf/b;
}

int prv[MX], nxt[MX];
map<pii, bool> done;

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for(int i=1; i<=n; i++) cin>>A[i], S[i]=S[i-1]+A[i];
    if(k==1){
        cout<<n;
        return 0;
    }
    for(int i=2; i<=n; i++){
        if(A[i-1]!=1) prv[i]=i-1;
        else prv[i]=prv[i-1];
    }
    nxt[n]=n+1;
    for(int i=n-1; i>=1; i--){
        if(A[i+1]!=1) nxt[i]=i+1;
        else nxt[i]=nxt[i+1];
    }

    for(int i=1; i<=n; i++){
        if(A[i]%k!=0) continue;
        int pos=i; ll p=A[i];
        while(prv[pos]!=0 && valid(p, A[prv[pos]])){
            p*=A[prv[pos]]; pos=prv[pos];
        }
        //cout<<pos<<' '<<i<<'\n';
        for(int l=pos; l<=i; l=nxt[l]){
            ll p=1;
            for(int x=l; x<i; x=nxt[x]) p*=A[x];
            for(int r=i; r<=n; r=nxt[r]){
                if(!valid(p, A[r])) break;
                p*=A[r];
                int lcnt=l-prv[l]-1, rcnt=nxt[r]-r-1;
                ll sum=S[r]-S[l-1];
                if(k*sum<=p && p<=k*(sum+lcnt+rcnt)){
                    if(done[pii(l,r)]) continue;
                    done[pii(l,r)]=true;
                    int cnt=p/k-sum;
                    int lmx=min(lcnt, cnt);
                    int lmn=max(0, cnt-rcnt);
                    ans+=(lmx-lmn+1);
                    //cout<<"!!:"<<l<<' '<<r<<'\n';
                }
            }
        }
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int MX=200010;
const ll inf=3e18;

int A[MX], n, k;
ll S[MX], ans;

bool valid(ll a, ll b){
    return a<=inf/b;
}

int nxt[MX];

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for(int i=1; i<=n; i++){
        cin>>A[i]; S[i]=S[i-1]+A[i];
    }
    nxt[n]=n+1;
    for(int i=n-1; i>=1; i--)
        nxt[i]=(A[i+1]==1 ? nxt[i+1] : i+1);

    for(int l=1; l<=n; l++){
        ll p=1;
        for(int r=l; r<=n; r=nxt[r]){
            if(!valid(p,A[r])) break;
            p*=A[r];
            ll sum=S[r]-S[l-1]; int cnt=nxt[r]-r-1;
            ans+=(k*sum<=p && p<=k*(sum+cnt)) ? 1 : 0;
        }
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int MX=200010;
const ll inf=3e18;

int A[MX], n, k;
ll S[MX], ans;

bool valid(ll a, ll b){
    return a<=inf/b;
}

int nxt[MX];

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for(int i=1; i<=n; i++){
        cin>>A[i]; S[i]=S[i-1]+A[i];
    }
    nxt[n]=n+1;
    for(int i=n-1; i>=1; i--)
        nxt[i]=(A[i+1]==1 ? nxt[i+1] : i+1);

    for(int l=1; l<=n; l++){
        ll p=1;
        for(int r=l; r<=n; r++){
            if(!valid(p,A[r])) break;
            p*=A[r];
            ans+=(p==k*(S[r]-S[l-1]));
        }
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int MX=200010;
const ll inf=3e18;

int A[MX], n, k;
ll S[MX], ans;

bool valid(ll a, ll b){
    return a<=inf/b;
}

int prv[MX], nxt[MX];

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for(int i=1; i<=n; i++) cin>>A[i], S[i]=S[i-1]+A[i];
    if(k==1){
        cout<<n;
        return 0;
    }
    for(int i=2; i<=n; i++){
        if(A[i-1]!=1) prv[i]=i-1;
        else prv[i]=prv[i-1];
    }
    nxt[n]=n+1;
    for(int i=n-1; i>=1; i--){
        if(A[i+1]!=1) nxt[i]=i+1;
        else nxt[i]=nxt[i+1];
    }

    for(int i=1; i<=n; i++){
        if(A[i]%k!=0) continue;
        int pos=i; ll p=A[i];
        while(prv[pos]!=0 && valid(p, A[prv[pos]])){
            p*=A[prv[pos]]; pos=prv[pos];
        }
        for(int l=pos; l<=i; l=nxt[l]){
            ll p=1;
            for(int x=l; x<i; x=nxt[x]) p*=A[x];
            for(int r=i; r<=n; r=nxt[r]){
                if(!valid(p, A[r])) break;
                p*=A[r];
                int lcnt=l-prv[l]-1, rcnt=nxt[r]-r-1;
                ll sum=S[r]-S[l-1];
                if(k*sum<=p && p<=k*(sum+lcnt+rcnt)){
                    int cnt=p/k-sum;
                    int lmx=min(lcnt, cnt);
                    int lmn=max(0, cnt-rcnt);
                    ans+=(lmx-lmn+1);
                }
            }
        }
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int MX=200010;
const ll inf=3e18;

int A[MX], n, k;
ll S[MX], ans;

bool valid(ll a, ll b){
    return a<=inf/b;
}

int prv[MX], nxt[MX];
map<pii, bool> done;

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for(int i=1; i<=n; i++) cin>>A[i], S[i]=S[i-1]+A[i];
    for(int i=2; i<=n; i++){
        if(A[i-1]!=1) prv[i]=i-1;
        else prv[i]=prv[i-1];
    }
    nxt[n]=n+1;
    for(int i=n-1; i>=1; i--){
        if(A[i+1]!=1) nxt[i]=i+1;
        else nxt[i]=nxt[i+1];
    }

    for(int i=1; i<=n; i++){
        if(A[i]%k!=0) continue;
        if(A[i]==1){
            if(k==1) done[pii(i,i)], ans++;
            continue;
        }
        int pos=i; ll p=A[i];
        while(prv[pos]!=0 && valid(p, A[prv[pos]])){
            p*=A[prv[pos]]; pos=prv[pos];
        }
        //cout<<pos<<' '<<i<<'\n';
        for(int l=pos; l<=i; l=nxt[l]){
            ll p=1;
            for(int x=l; x<i; x=nxt[x]) p*=A[x];
            for(int r=i; r<=n; r=nxt[r]){
                if(!valid(p, A[r])) break;
                p*=A[r];
                int lcnt=l-prv[l]-1, rcnt=nxt[r]-r-1;
                ll sum=S[r]-S[l-1];
                if(k*sum<=p && p<=k*(sum+lcnt+rcnt)){
                    if(done[pii(l,r)]) continue;
                    done[pii(l,r)]=true;
                    int cnt=p/k-sum;
                    int lmx=min(lcnt, cnt);
                    int lmn=max(0, cnt-rcnt);
                    ans+=(lmx-lmn+1);
                    //cout<<"!!:"<<l<<' '<<r<<'\n';
                }
            }
        }
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int MX=200010;
const ll inf=3e18;

int A[MX], n, k;
ll S[MX], ans;

bool valid(ll a, ll b){
    return a<=inf/b;
}

int prv[MX], nxt[MX];
map<pii, bool> done;

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for(int i=1; i<=n; i++) cin>>A[i], S[i]=S[i-1]+A[i];
    for(int i=2; i<=n; i++){
        if(A[i-1]!=1) prv[i]=i-1;
        else prv[i]=prv[i-1];
    }
    nxt[n]=n+1;
    for(int i=n-1; i>=1; i--){
        if(A[i+1]!=1) nxt[i]=i+1;
        else nxt[i]=nxt[i+1];
    }

    for(int i=1; i<=n; i++){
        if(A[i]%k!=0) continue;
        int pos=i; ll p=A[i];
        while(prv[pos]!=0 && valid(p, A[prv[pos]])){
            p*=A[prv[pos]]; pos=prv[pos];
        }
        //cout<<pos<<' '<<i<<'\n';
        for(int l=pos; l<=i; l=nxt[l]){
            ll p=1;
            for(int x=l; x<i; x=nxt[x]) p*=A[x];
            for(int r=i; r<=n; r=nxt[r]){
                if(!valid(p, A[r])) break;
                p*=A[r];
                int lcnt=l-prv[l]-1, rcnt=nxt[r]-r-1;
                ll sum=S[r]-S[l-1];
                if(k*sum<=p && p<=k*(sum+lcnt+rcnt)){
                    if(done[pii(l,r)]) continue;
                    done[pii(l,r)]=true;
                    int cnt=p/k-sum;
                    int lmx=min(lcnt, cnt);
                    int lmn=max(0, cnt-rcnt);
                    ans+=(lmx-lmn+1);
                    //cout<<"!!:"<<l<<' '<<r<<'\n';
                }
            }
        }
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int MX=200010;
const ll inf=3e18;

int A[MX], n, k;
ll S[MX], ans;

bool valid(ll a, ll b){
    return a<=inf/b;
}

int nxt[MX];

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for(int i=1; i<=n; i++){
        cin>>A[i]; S[i]=S[i-1]+A[i];
    }
    nxt[n]=n+1;
    for(int i=n-1; i>=1; i--)
        nxt[i]=(A[i+1]==1 ? nxt[i+1] : i+1);

    for(int l=1; l<=n; l++){
        ll p=1;
        for(int r=l; r<=n; r=nxt[r]){
            if(!valid(p,A[r])) break;
            p*=A[r];
            ll sum=S[r]-S[l-1]; int cnt=nxt[r]-r-1;
            ans+=(k*sum<=p && p<=k*(sum+cnt));
        }
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=211111;
long long n,k,a[maxn],sum[maxn],to[maxn];
int main(){
	cin>>n>>k;
	bool is1=1;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]!=1)is1=0;
		sum[i]=sum[i-1]+a[i];
	}
	int r;
	for(int i=1;i<=n;i++){
		if(a[i]==1){
			r=i;
			while(a[r+1]==1)r++;
			to[i]=r;
			i=r;
		}
	}
	if(is1){
		cout<<n<<endl;
		return 0;
	}
	long long ans=0;
	for(int i=1;i<=n;i++){
		long long ji=0,c=1;
		for(int j=i;j<=n;j++){
			if(a[j]==1){
				//cout<<i<<" -> "<<j<<" : "<<c<<" "<<ji<<endl;
				if(c>ji*k&&c<=k*(ji+to[j]-j+1)&&c%k==0)ans++;
				ji+=to[j]-j+1;
				j=to[j];
				continue;
			}
			c*=a[j];
			ji+=a[j];
			if(c>k*(ji+sum[n]-sum[j]))break;
			if(c==ji*k)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn = (int)2e5 + 5;
const long long inf = 3e18;
int n, k, a[maxn];
long long ls[maxn], ans;

inline void qiu1() {
	for (int i = n; i >= 1; i--)
		if (a[i] == 1)
			ls[i] = a[i + 1] == 1 ? ls[i + 1] : i;
}

inline int anc(long long x, long long y) {

}

inline bool check(long long x, long long y) { return 1.0 * x * y  <= inf; }

int main() {
//	freopen ("interval.in", "r", stdin);
//	freopen ("interval.out", "w", stdout);
	scanf ("%d%d", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf ("%d", &a[i]);
	qiu1();
	for (int i = 1; i <= n; i++) {
		long long poss = 1, s = 0;
		for (int j = i; j <= n; j++) {
			if (a[j] == 1) {
				int y = ls[j];
				int cnt = y - j + 1;
				if (poss % k == 0) {
					long long t = poss / k - s;
					if (t >= 1 && t <= cnt)
						ans++;
					}
					j = y;
					s += cnt;
				} else {
					if (!check(poss, a[j]))
						break;
					poss *= a[j], s += a[j];
					if (poss % k == 0 && poss/k == s)
						ans++;
			}
		}
	}
	printf ("%I64d", ans);
	return 0;
}


#include <bits/stdc++.h>
#define il inline
#define re register
#define ll long long
using namespace std;
template<class T>
il void read(T &x){
    x=0;
    static char ch=getchar();
    while(ch<'0'||ch>'9')   ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}
const ll inf = 2e18;
const int maxn = 2e5 + 10;
int n, k, la[maxn];//左端1的位置
ll a[maxn], ans;
int main() {
	read(n), read(k);
	for(re int i = 1; i <= n; ++i) {
		read(a[i]);
		if(a[i-1] != 1) la[i] = i-1;
		else la[i] = la[i-1];
	}
	for(re int i = 1; i <= n; ++i) {
		ll sum = a[i], mul = a[i];//从i往左选
		if(sum*k == mul) ans++;
		for(re ll pre = i, now = la[i]; ;pre = now, now = la[now]) {
			ll cnt = mul - sum*k;
			if(cnt > 0&&cnt % k==0&&cnt/k < pre-now) ans++;
			//有足够多的1来填补
			if(mul > inf/a[now]||!now) break;//出界了
			mul *= a[now], sum += a[now]+(pre-now-1);
			if(mul == sum*k) ans++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#define MAX 1<<63
#define INF 2333330303.3
#define rg register
#define abs(a) ((a)>0?(a):-(a))
#define ll long long
using namespace std;
const int maxn=450000;
namespace io
{
    static char B[1<<24],*S=B;
    inline void in()
    {
        fread(B,1,1<<24,stdin);
    }
    inline ll read()
    {
        rg bool bo=0;
        for(;*S<'-';S++);
        rg ll x=*S++-'0';
        for(;*S>='0';x=(x<<3)+(x<<1)+*S++-'0');
        return bo?-x:x;
    }
    static char Buf[1<<26],*O=Buf,Stk[20];
    inline void write(rg ll x)
    {
        rg ll Ts=0;
        if(x==0)
            *O++='0';
        for(;x;)
            Stk[++Ts]=x%10,x/=10;
        for(;Ts;)
            *O++='0'+Stk[Ts--];
        *O++='\n';
    }
    inline void out()
    {
        fwrite(Buf,1,O-Buf,stdout),O=Buf;
    }
}
using namespace io;
inline ll max(ll a,ll b)
{
    if(a>b) return a;
    return b;
}
inline ll min(ll a,ll b)
{
    if(a>b) return b;
    return a;
}
ll a[maxn],s[maxn];
int n,k;
ll Left[maxn];
ll x,tag,tot;
int main()
{
	in();
    n=read();
    k=read();
    for(rg int i=1;i<=n;++i)
    {
        a[i]=read();
        s[i]=s[i-1]+a[i];
    }
    //求出所有点左边第一个不为1的数的位置
    for(rg int i=1;i<=n;++i)
    {
        if(a[i-1]!=1)
        {
            Left[i]=i-1;
        }
        else
        {
            Left[i]=Left[i-1];
        }
    }
    for(rg int i=1;i<=n;++i)
    {
        ll sum1=a[i];
        ll sum2=a[i];
        if(sum2==sum1*k)
        {
            ++tot;
        }
        for(rg int j=i,now=Left[i];;now=Left[now],j=Left[j])
        {
            ll res=sum2-sum1*k;
            if(res>0&&res%k==0&&res/k<j-now)//当res,且整除k，并且除K后的值小于连续一段1
            {
                tot++;//此时一定能在这连续的1中找到一个值满足sum2/sum1=k
            }
            if(now==0||res>MAX)//左边全是1了 或者乘积已经过大了,就完全没必要继续下去了
            {
                break;
            }
            sum1+=s[j-1]-s[Left[j]-1];
            sum2*=a[Left[j]];
            if(sum2==sum1*k)
            {
                ++tot;
            }
        }
    }
	write(tot);
	out();
}


#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#define MAX 2000000000
#define INF 2333330303.3
#define rg register
#define abs(a) ((a)>0?(a):-(a))
#define ll long long
using namespace std;
const int maxn=1250000;
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
inline void print(ll x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>=10)
    {
        print(x/10);
    }
    putchar(x%10+'0');
}
inline ll max(ll a,ll b)
{
    if(a>b) return a;
    return b;
}
inline ll min(ll a,ll b)
{
    if(a>b) return b;
    return a;
}
ll a[maxn],s[maxn];
int n,k;
ll Left[maxn];
ll x,tag,tot;
int main()
{
	n=read();
	k=read();
	for(rg int i=1;i<=n;++i)
	{
		a[i]=read();
		s[i]=s[i-1]+a[i];
	}
	//求出所有点左边第一个不为1的数的位置
	for(rg int i=1;i<=n;++i)
	{
		if(a[i-1]!=1)
		{
			Left[i]=i-1;
		}
		else
		{
			Left[i]=Left[i-1];
		}
	}
	for(rg int i=1;i<=n;++i)
	{
		ll sum1=a[i];
		ll sum2=a[i];
		if(sum2==sum1*k)
		{
			++tot;
		}
		for(rg int j=i;j>=1;j=Left[j])
		{
			ll res=sum2-sum1*k;
			if(res>0&&res%k==0&&res/k<j-Left[j])//当res,且整除k，并且除K后的值小于连续一段1
			{
				tot++;//此时一定能在这连续的1中找到一个值满足sum2/sum1=k
			}
			if(Left[j]==0)//左边全是1了
			{
				break;
			}
			sum1+=s[j-1]-s[Left[j]-1];
			sum2*=a[Left[j]];
			if(sum2==sum1*k)
			{
				tot++;
			}
		}
	}
	cout<<tot;
}


#include <cstdio>
#define int long long
const long long  MLL = 9223372036854775807;

using namespace std;

int N,K,a[201000],lr[201000],ans,del_M,del_N;

signed main()
{
    scanf("%lld%lld",&N,&K);
    for(int i = 1 ; i <= N ; i ++ )scanf("%lld",&a[i]),lr[i] = (a[i - 1] == 1 ? lr[i - 1]:i - 1);
    for(int i = 1 ; i <= N ; i ++ )
    {
        int mul = a[i],sum = a[i];
        for(int l = lr[i] ,r = i ; ; r = l , l = lr[l])
        {
            del_M = mul - K*sum;del_N = r - l - 1;
            if(del_M > 0 && del_M % K == 0 && del_N *K >= del_M )ans ++;
            if(MLL/(sum + del_N)< mul || l == 0 )break;
            sum += a[l] + del_N;
            mul *= a[l];
            ans+= K*sum == mul;
        }
    }
    printf("%lld",ans + (K == 1?N:0));
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;
map<int,int>mp;
typedef long long ll;
#define inf 0x3f3f3f
char s[200005];
int vis[20];
ll a[200005];
ll nxt[200005];
int b[20];
ll n;
void build()
{
    int i,x=n+1;
    for(i=n; i>=1; i--)
    {
        nxt[i]=x;
        if(a[i]!=1)
        {
            x=i;
        }
    }
}
int main()
{
    ll k;
    int i;
    cin>>n>>k;
    build();
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
    }

    ll cnt=0;
    for(i=1; i<=n; i++)
    {
        ll ans=1,sum=0;
        int j=i;
        while(j<=n)
        {
            if(ans*a[j]>2e18)
            {
                break;
            }
            ans*=a[j];
            sum+=a[j];
            ll y=nxt[j]-j-1;
            if(ans%sum==0)
            {
                if(sum<=ans/k&&(sum+y)>=ans/k)
                {
                    cnt++;
                }
            }
            sum+=y;
            j=nxt[j];
        }

    }
    printf("%lld\n",cnt);

    return 0;
}


#include <cstdio>
#define int long long
const long long  MLL = 9223372036854775807;

using namespace std;

int N,K,a[201000],lr[201000],ans,del_M,del_N;

signed main()
{
    scanf("%lld%lld",&N,&K);
    for(int i = 1 ; i <= N ; ++ i )scanf("%lld",&a[i]),lr[i] = a[i - 1] == 1 ? lr[i - 1]:i - 1;
    for(int i = 1 ; i <= N ; ++ i )
    {
        int mul = a[i],sum = a[i];
        for(int l = lr[i] ,r = i ; ; r = l , l = lr[l])
        {
            del_M = mul - K*sum;;
            if(del_M > 0 && del_M % K == 0 && (r - l - 1) *K >= del_M )ans ++;
            if(MLL/sum < mul || l == 0 )break;
            sum += a[l] + (r - l - 1 );mul *= a[l];
            ans+= K*sum == mul;
        }
    }
    printf("%lld",ans + (K == 1?(long long )N:0ll));
    return 0;
}


#ifndef HOME
	#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define gcd(x, y) __gcd((x), (y))
using namespace std;

using i64 = long long;

const int N = 2e5 + 5;

i64 v[N];
int len[N];

i64 ant, k, p, s;
int n;

int main() {
#ifdef HOME
	freopen("cf.in", "r", stdin);
	freopen("cf.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> v[i];

	for (int i = n; i >= 1; --i) if (v[i] == 1)
		len[i] = 1 + len[i + 1];

	for (int j, i = 1; i <= n; ++i) {
		s = p = v[i];
		if (s * k == p)
			ant+= 1;

		for (j = i + 1; j <= n; ++j) {
			if (p - s * k >= (n - i + 1) * k) //unrecoverable
				break;

			if (v[j] == 1) { // 1-segment
				if (len[j] * k >= p - s * k && p % k == 0 && p - s * k > 0)
					ant+= 1;
				j+= len[j] - 1;
				s+= len[j];
				continue; }

			p*= v[j]; //just advance
			s+= v[j];
			if (s * k == p)
				ant+= 1; } }

	cout << ant << endl;

	return 0; }


#include <bits/stdc++.h>
#define gcd(x, y) __gcd((x), (y))
using namespace std;

using i64 = long long;

const int N = 2e5 + 5;

i64 v[N];
int len[N];

i64 ant, k, p, s;
int n;

int main() {
#ifdef HOME
	freopen("cf.in", "r", stdin);
	freopen("cf.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> v[i];

	for (int i = n; i >= 1; --i) if (v[i] == 1)
		len[i] = 1 + len[i + 1];

	for (int j, i = 1; i <= n; ++i) {
		s = p = v[i];
		if (s * k == p)
			ant+= 1;

		for (j = i + 1; j <= n; ++j) {
			if (p - s * k >= n * k) //unrecoverable
				break;

			if (v[j] == 1 && p - s * k > 0) { // 1-segment
				if (len[j] * k >= p - s * k && p % k == 0)
					ant+= 1;
				j+= len[j] - 1;
				s+= len[j];
				continue; }

			p*= v[j]; //just advance
			s+= v[j];
			if (s * k == p)
				ant+= 1; } }

	cout << ant << endl;

	return 0; }


#ifndef HOME
	#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define gcd(x, y) __gcd((x), (y))
using namespace std;

using i64 = long long;

const int N = 2e5 + 5;

i64 v[N];
int len[N];

i64 ant, k, p, s;
int n;

int main() {
#ifdef HOME
	freopen("cf.in", "r", stdin);
	freopen("cf.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> v[i];

	for (int i = n; i >= 1; --i) if (v[i] == 1)
		len[i] = 1 + len[i + 1];

	for (int j, i = 1; i <= n; ++i) {
		s = p = v[i];
		if (s * k == p)
			ant+= 1;

		for (j = i + 1; j <= n; ++j) {
			if (p - s * k >= (n - i + 1) * k) //unrecoverable
				break;

			if (v[j] == 1 && p - s * k > 0) { // 1-segment
				if (len[j] * k >= p - s * k && p % k == 0)
					ant+= 1;
				j+= len[j] - 1;
				s+= len[j];
				continue; }

			p*= v[j]; //just advance
			s+= v[j];
			if (s * k == p)
				ant+= 1; } }

	cout << ant << endl;

	return 0; }


#ifndef HOME
	#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define gcd(x, y) __gcd((x), (y))
using namespace std;

using i64 = long long;

const int N = 2e5 + 5;

i64 v[N];
int len[N];

i64 ant, k, p, s;
int n;

int main() {
#ifdef HOME
	freopen("cf.in", "r", stdin);
	freopen("cf.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> v[i];

	for (int i = n; i >= 1; --i) if (v[i] == 1)
		len[i] = 1 + len[i + 1];

	for (int j, i = 1; i <= n; ++i) {
		s = p = v[i];
		if (s * k == p)
			ant+= 1;

		for (j = i + 1; j <= n; ++j) {
			if (p - (s + n) * k >= 0) //unrecoverable
				break;

			if (v[j] == 1) { // 1-segment
				if (p - (s + len[j]) * k <= 0 && 0 <= p - (s + 1) * k && p % k == 0)
					ant+= 1;
				j+= len[j] - 1;
				s+= len[j];
				continue; }

			p*= v[j]; //just advance
			s+= v[j];
			if (s * k == p)
				ant+= 1; } }

	cout << ant << endl;

	return 0; }


#ifndef HOME
	#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define gcd(x, y) __gcd((x), (y))
using namespace std;

using i64 = long long;

const int N = 2e5 + 5;

i64 v[N];
int len[N];

i64 ant, k, p, s;
int n;

int main() {
#ifdef HOME
	freopen("cf.in", "r", stdin);
	freopen("cf.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> v[i];

	for (int i = n; i >= 1; --i) if (v[i] == 1)
		len[i] = 1 + len[i + 1];

	if (k == 1) {
		cout << n << endl;
		return 0; }

	for (int j, i = 1; i <= n; ++i) {
		s = p = v[i];
		if (s * k == p)
			ant+= 1;

		for (j = i + 1; j <= n; ++j) {
			if (p - (s + n) * k >= 0) //unrecoverable
				break;

			if (v[j] == 1) { // 1-segment
				if (p - (s + len[j]) * k <= 0 && 0 <= p - (s + 1) * k && p % k == 0)
					ant+= 1;
				j+= len[j] - 1;
				s+= len[j];
				continue; }

			p*= v[j]; //just advance
			s+= v[j];
			if (s * k == p)
				ant+= 1; } }

	cout << ant << endl;

	return 0; }


#ifndef HOME
	#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define gcd(x, y) __gcd((x), (y))
using namespace std;

using i64 = long long;

const int N = 2e5 + 5;

i64 v[N];
int len[N];

i64 ant, k, p, s;
int n;

int main() {
#ifdef HOME
	freopen("cf.in", "r", stdin);
	freopen("cf.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> v[i];

	for (int i = n; i >= 1; --i) if (v[i] == 1)
		len[i] = 1 + len[i + 1];

	if (k == 1) {
		cout << n << endl;
		return 0; }

	for (int j, i = 1; i <= n; ++i) {
		s = p = v[i];
		if (s * k == p)
			ant+= 1;

		for (j = i + 1; j <= n; ++j) {
			if (p - s * k >= n * k) //unrecoverable
				break;

			if (v[j] == 1) { // 1-segment
				if (len[j] * k >= p - s * k && p % k == 0 && p - (s + 1) * k >= 0)
					ant+= 1;
				j+= len[j] - 1;
				s+= len[j];
				continue; }

			p*= v[j]; //just advance
			s+= v[j];
			if (s * k == p)
				ant+= 1; } }

	cout << ant << endl;

	return 0; }


#ifndef HOME
	#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define gcd(x, y) __gcd((x), (y))
using namespace std;

using i64 = long long;

const int N = 2e5 + 5;

i64 v[N];
int len[N];

i64 ant, k, p, s;
int n;

int main() {
#ifdef HOME
	freopen("cf.in", "r", stdin);
	freopen("cf.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> v[i];

	for (int i = n; i >= 1; --i) if (v[i] == 1)
		len[i] = 1 + len[i + 1];

	if (k == 1) {
		cout << n << endl;
		return 0; }

	for (int j, i = 1; i <= n; ++i) {
		s = p = v[i];
		if (s * k == p)
			ant+= 1;

		for (j = i + 1; j <= n; ++j) {
			if (p - s * k >= n * k) //unrecoverable
				break;

			if (v[j] == 1) { // 1-segment
				if (len[j] * k >= p - s * k && p % k == 0 && p - s * k > 0)
					ant+= 1;
				j+= len[j] - 1;
				s+= len[j];
				continue; }

			p*= v[j]; //just advance
			s+= v[j];
			if (s * k == p)
				ant+= 1; } }

	cout << ant << endl;

	return 0; }


#ifndef HOME
	#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define gcd(x, y) __gcd((x), (y))
using namespace std;

using i64 = long long;

const int N = 2e5 + 5;

i64 v[N];
int len[N];

i64 ant, k, p, s;
int n;

int main() {
#ifdef HOME
	freopen("cf.in", "r", stdin);
	freopen("cf.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> v[i];

	for (int i = n; i >= 1; --i) if (v[i] == 1)
		len[i] = 1 + len[i + 1];

	for (int j, i = 1; i <= n; ++i) {
		s = p = v[i];
		if (s * k == p)
			ant+= 1;

		for (j = i + 1; j <= n; ++j) {
			if (p - (s + n) * k >= 0) //unrecoverable
				break;

			if (v[j] == 1) { // 1-segment
				if (p - (s + len[j]) * k <= 0 && 0 <= p - (s + 1) * k && p % k == 0)
					ant+= 1;
				s+= len[j];
				j+= len[j] - 1;
				continue; }

			p*= v[j]; //just advance
			s+= v[j];
			if (s * k == p)
				ant+= 1; } }

	cout << ant << endl;

	return 0; }


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int const N = 202020;
ll a[N];
ll l[N], r[N];
int main() {
  int n; ll k; scanf("%d%I64d", &n, &k);
  Rep(i, n) scanf("%I64d", &a[i]);
  Rep(i, n) l[i] = a[i - 1] == 1 ? 1 + l[i - 1] : 0;
  for (int i = n; i >= 1; --i) r[i] = a[i + 1] == 1 ? 1 + r[i + 1] : 0;
  ll mx = Inf;
  ll ans = 0;
  if (k == 1) {
    Rep(i, n) if (a[i] == 1) ++ans;
  }
  Rep(i, n) if (a[i] != 1) {
    ll ts = 0, tr = 1;
    for (int j = i; j <= n; ++j) {
      if (a[j] == 1) {
        ts += r[j - 1];
        j += r[j - 1];
        j -= 1;
        continue;
      }
      if (tr > mx / a[j]) break;
      ts += a[j]; tr *= a[j];
      if (tr % k == 0) {
        ll need = tr / k - ts;
        if (need >= 0) {
          ll lc = min(need, l[i]), rc = min(need, r[j]);
          int cnt = lc + rc - need + 1;
          cnt = max(cnt, 0);
          ans += cnt;
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int const N = 202020;
ll a[N];
ll l[N], r[N];
int main() {
  int n; ll k; scanf("%d%I64d", &n, &k);
  Rep(i, n) scanf("%I64d", &a[i]);
  Rep(i, n) l[i] = a[i - 1] == 1 ? 1 + l[i - 1] : 0;
  for (int i = n; i >= 1; --i) r[i] = a[i + 1] == 1 ? 1 + r[i + 1] : 0;
  ll sum = 0; Rep(i, n) sum += a[i];
  ll mx = k * sum;
  ll ans = 0;
  if (k == 1) {
    Rep(i, n) if (a[i] == 1) ++ans;
  }
  Rep(i, n) if (a[i] != 1) {
    ll ts = 0, tr = 1;
    for (int j = i; j <= n; ++j) {
      if (a[j] == 1) {
        ts += r[j - 1];
        j += r[j - 1];
        j -= 1;
        continue;
      }
      if (tr > mx / a[j]) break;
      ts += a[j]; tr *= a[j];
      ll need = tr - ts * k;
      if (need >= 0 && need % k == 0) {
        need /= k;
        ll lc = min(need, l[i]), rc = min(need, r[j]);
        int cnt = lc + rc - need + 1;
        cnt = max(cnt, 0);
        ans += cnt;
      }
    }
  }

  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int const N = 202020;
ll a[N];
ll l[N], r[N];
int main() {
  int n; ll k; scanf("%d%I64d", &n, &k);
  Rep(i, n) scanf("%I64d", &a[i]);
  Rep(i, n) l[i] = a[i - 1] == 1 ? 1 + l[i - 1] : 0;
  for (int i = n; i >= 1; --i) r[i] = a[i + 1] == 1 ? 1 + r[i + 1] : 0;
  ll mx = Inf;
  ll ans = 0;
  if (k == 1) {
    Rep(i, n) if (a[i] == 1) ++ans;
  }
  Rep(i, n) if (a[i] != 1) {
    ll ts = 0, tr = 1;
    for (int j = i; j <= n; ++j) {
      if (a[j] == 1) {
        ts += r[j - 1];
        j += r[j - 1];
        j -= 1;
        continue;
      }
      if (tr > mx / a[j]) break;
      ts += a[j]; tr *= a[j];
      if (tr % k == 0) {
        ll need = tr / k - ts;
        if (need >= 0) {
          ll lc = min(need, l[i]), rc = min(need, r[j]);
          ll cnt = lc + rc - need + 1;
          cnt = max(cnt, 0LL);
          ans += cnt;
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int const N = 202020;
ll a[N];
ll l[N], r[N];
int main() {
  int n; ll k; scanf("%d%I64d", &n, &k);
  Rep(i, n) scanf("%I64d", &a[i]);
  Rep(i, n) l[i] = a[i - 1] == 1 ? 1 + l[i - 1] : 0;
  for (int i = n; i >= 1; --i) r[i] = a[i + 1] == 1 ? 1 + r[i + 1] : 0;
  ll sum = 0; Rep(i, n) sum += a[i];
  ll mx = k * sum;
  ll ans = 0;
  if (k == 1) {
    Rep(i, n) if (a[i] == 1) ++ans;
  }
  Rep(i, n) if (a[i] != 1) {
    ll ts = 0, tr = 1;
    for (int j = i; j <= n; ++j) {
      if (a[j] == 1) {
        ts += r[j - 1];
        j += r[j - 1];
        j -= 1;
        continue;
      }
      if (tr > mx / a[j]) break;
      ts += a[j]; tr *= a[j];
      if (tr % k == 0) {
        ll need = tr / k - ts;
        if (need >= 0) {
          ll lc = min(need, l[i]), rc = min(need, r[j]);
          int cnt = lc + rc - need + 1;
          cnt = max(cnt, 0);
          ans += cnt;
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int const N = 202020;
ll a[N];
ll l[N], r[N];
int main() {
  int n; ll k; scanf("%d%I64d", &n, &k);
  Rep(i, n) scanf("%I64d", &a[i]);
  Rep(i, n) l[i] = a[i - 1] == 1 ? 1 + l[i - 1] : 0;
  for (int i = n; i >= 1; --i) r[i] = a[i + 1] == 1 ? 1 + r[i + 1] : 0;
  ll sum = 0; Rep(i, n) sum += a[i];
  ll mx = k * sum;
  ll ans = 0;
  if (k == 1) {
    Rep(i, n) if (a[i] == 1) ++ans;
  }
  Rep(i, n) if (a[i] != 1) {
    ll ts = 0, tr = 1;
    for (int j = i; j <= n; ++j) {
      if (a[j] == 1) {
        ts += r[j - 1];
        j += r[j - 1];
        j -= 1;
        continue;
      }
      if (tr > mx / a[j]) break;
      ts += a[j]; tr *= a[j];
      ll need = tr - ts * k;
      if (need % k == 0) {
        need /= k;
        ll lc = min(need, l[i]), rc = min(need, r[j]);
        int cnt = lc + rc - need + 1;
        cnt = max(cnt, 0);
        ans += cnt;
      }
    }
  }

  cout << ans << endl;
  return 0;
}


#include<bits/stdc++.h>
#define N 200005
#define ll long long
using namespace std;
template<class T>
inline void read(T &x)
{
    x=0;
    static char ch=getchar();
    while(ch<'0'||ch>'9')   ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}
int n,le[N],ans;
ll k,a[N];
inline bool Overflow(ll mul,ll x)
{
    if(mul>LLONG_MAX/x) return true;
    return false;
}
int main()
{
    read(n);    read(k);
    for(int i=1;i<=n;i++)   read(a[i]);
    for(int i=1;i<=n;i++)
    {
        if(a[i-1]!=1) le[i]=i-1;
        else le[i]=le[i-1];
    }
    for(int i=1;i<=n;i++)
    {
        ll sum=a[i],mul=a[i];
        if(mul==sum*k)  ans++;
        for(int pre=i,now=le[i];;pre=now,now=le[now])
        {
            ll del=mul-sum*k;
            if(del>0&&del%k==0&&del/k<pre-now)  ans++;
            if(!now||Overflow(mul,a[now]))  break;
            mul*=a[now]; sum+=a[now]+(pre-now-1);
            if(mul==sum*k)  ans++;
        }
    }
    cout<<ans<<endl;;
    return 0;
}


#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#define LL long long
#define Rg register
#define RI register int
#define RC register char
#define ed puts("")
#define pair pair<LL,LL>
#define space putchar(' ')
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;

template <typename tp> inline void read(tp & x)
{
    x=0;
    RI f=1;
    RC c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar(); }
    while(c>='0' && c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
 	x*=f;
}

template <typename Tp> inline void print(Tp x)
{
    if(x<0) x=-x,putchar('-');
    if(x>9) print(x/10);
    putchar(x%10+'0');
}

int n,k;
LL a[1000005];
int last[10000005];//last[i]表示自i开始前面第一个不是1的位置
LL ans;
LL sum,mul;
const LL xzy=2e13;

int main()
{
	read(n),read(k);
	for(RI i=1;i<=n;++i)
		read(a[i]);
	for(RI i=1;i<=n;++i)
	{
		if(a[i-1]!=1)
			last[i]=i-1;
		else
			last[i]=last[i-1];
	}
	for(RI i=1;i<=n;++i)
	{
		sum=a[i];
		mul=a[i];
		if(k==1) ans++;
		for(RI j=i,qwq=last[i];;j=qwq,qwq=last[qwq])//这种遍历方式即可跳过一段连续的1且是从后往前遍历
		{
			int len=j-qwq;//连续一段1的长度
			if((mul-sum*k)>0 && (mul-sum*k)%k==0 && (mul-sum*k)/k<len)
				ans++;
			if(qwq==0 || mul*a[qwq]>xzy)
				break;//爆出sum的最大值或者已经到了第一个数
			mul*=a[qwq],sum+=a[qwq]+(j-qwq-1);
			if(mul-sum*k==0) ans++;
		}
	}
	print(ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,cur;
int b[305];
int a[2][105];
bool judge(int x,int n)
{
	if(x==0)return false;
	if(n>=a[cur^1][x])
	{
		if(a[cur^1][x]==9)return judge(x-1,n-9);
		else return true;
	}
	else return false;
}
int main()
{
//	freopen("input.txt","r",stdin);
	while(scanf("%d",&n)==1)
	{
        for(int i=1;i<=n;i++)scanf("%d",&b[i]);
        memset(a,0,sizeof(a));
        cur=0;
        a[1][0]=1;a[1][1]=0;
        for(int i=1;i<=n;i++)
		{
			memset(a[cur],0,sizeof(a[cur]));
			while(a[cur][0]*9<b[i])a[cur][0]++;
			if(b[i]>a[cur^1][a[cur^1][0]])
			{
                if(a[cur^1][a[cur^1][0]]==9)
				{
					if(judge(a[cur^1][0],b[i]))a[cur][0]=max(a[cur][0],a[cur^1][0]);
					else a[cur][0]=max(a[cur][0],a[cur^1][0]+1);
				}
				else a[cur][0]=max(a[cur][0],a[cur^1][0]);
			}
            else a[cur][0]=max(a[cur][0],a[cur^1][0]+1);
//            if(i==2)cout<<a[cur][0]<<' '<<a[cur^1][0]<<endl;
			bool larger=true;
			bool done=false;
			if(a[cur][0]>a[cur^1][0])done=true;
            for(int j=a[cur][0];j>0;j--)
			{
				a[cur][j]=(j==a[cur][0]?1:0);
//				if(i==6&&j==1)cout<<b[i]<<endl;
                while(a[cur][j]+(j-1)*9<b[i])a[cur][j]++;
//                if(i==2&&j==1){cout<<a[cur][j]<<endl;cout<<done<<endl;}

                if(!done)
				{
					a[cur][j]=max(a[cur^1][j],a[cur][j]);
					if(j-1<=0||(j-1>0&&b[i]-a[cur][j]<=a[cur^1][j-1])){done=true;larger=false;}
				}
                if(done&&!larger)
				{
					while(a[cur][j]<=a[cur^1][j])a[cur][j]++;
//					if(j-1<=0)while(a[cur][j]<b[i])a[cur][j]++;
					larger=true;
				}
//                if(i==6&&j==2)cout<<done<<endl;
                b[i]-=a[cur][j];
			}
			for(int j=a[cur][0];j>=1;j--)printf("%d",a[cur][j]);printf("\n");
			cur^=1;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
int b[305];
int a[2][105];
int main()
{
//  freopen("input.txt","r",stdin);
    while(scanf("%d",&n)==1)
    {
        for(int i=1;i<=n;i++)scanf("%d",&b[i]);
        memset(a,0,sizeof(a));
        int cur=0;
        a[1][0]=1;a[1][1]=0;
        for(int i=1;i<=n;i++)
        {
            memset(a[cur],0,sizeof(a[cur]));
            while(a[cur][0]*9<b[i])a[cur][0]++;
            a[cur][0]=a[cur^1][0];
            if(b[i]<=a[cur^1][a[cur^1][0]])a[cur][0]++;
//            if(i==6)cout<<a[cur][0]<<' '<<a[cur^1][0]<<endl;
            bool larger=true;
            bool done=false;
            if(a[cur][0]>a[cur^1][0])done=true;
            for(int j=a[cur][0];j>0;j--)
            {
                a[cur][j]=(j==a[cur][0]?1:0);
//              if(i==6&&j==1)cout<<b[i]<<endl;
                while(a[cur][j]+(j-1)*9<b[i])a[cur][j]++;
//                if(i==2&&j==1){cout<<a[cur][j]<<endl;cout<<done<<endl;}

                if(!done)
                {
                    a[cur][j]=a[cur^1][j];
                    if(j-1<=0||(j-1>0&&b[i]-a[cur][j]<=a[cur^1][j-1])){done=true;larger=false;}
                }
                if(done&&!larger)
                {
                    while(a[cur][j]<=a[cur^1][j])a[cur][j]++;
                    if(j-1<=0)while(a[cur][j]<b[i])a[cur][j]++;
                    larger=true;
                }
//                if(i==6&&j==2)cout<<done<<endl;
                b[i]-=a[cur][j];
            }
            for(int j=a[cur][0];j>=1;j--)printf("%d",a[cur][j]);printf("\n");
            cur^=1;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
int b[305];
int a[2][105];
int main()
{
//	freopen("input.txt","r",stdin);
	while(scanf("%d",&n)==1)
	{
        for(int i=1;i<=n;i++)scanf("%d",&b[i]);
        memset(a,0,sizeof(a));
        int cur=0;
        a[1][0]=1;a[1][1]=0;
        for(int i=1;i<=n;i++)
		{
			memset(a[cur],0,sizeof(a[cur]));
			while(a[cur][0]*9<b[i])a[cur][0]++;
			if(b[i]>a[cur^1][a[cur^1][0]])a[cur][0]=max(a[cur][0],a[cur^1][0]);
            else a[cur][0]=max(a[cur][0],a[cur^1][0]+1);
//            if(i==6)cout<<a[cur][0]<<' '<<a[cur^1][0]<<endl;
			bool larger=true;
			bool done=false;
			if(a[cur][0]>a[cur^1][0])done=true;
            for(int j=a[cur][0];j>0;j--)
			{
				a[cur][j]=(j==a[cur][0]?1:0);
//				if(i==6&&j==1)cout<<b[i]<<endl;
                while(a[cur][j]+(j-1)*9<b[i])a[cur][j]++;
//                if(i==2&&j==1){cout<<a[cur][j]<<endl;cout<<done<<endl;}

                if(!done)
				{
					a[cur][j]=a[cur^1][j];
					if(j-1<=0||(j-1>0&&b[i]-a[cur][j]<=a[cur^1][j-1])){done=true;larger=false;}
				}
                if(done&&!larger)
				{
					while(a[cur][j]<=a[cur^1][j])a[cur][j]++;
					if(j-1<=0)while(a[cur][j]<b[i])a[cur][j]++;
					larger=true;
				}
//                if(i==6&&j==2)cout<<done<<endl;
                b[i]-=a[cur][j];
			}
			for(int j=a[cur][0];j>=1;j--)printf("%d",a[cur][j]);printf("\n");
			cur^=1;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define Nmax 1005
#define INF 2000000000
#define eps 0.000000000001

using namespace std;

int sum[Nmax],last[Nmax],a[Nmax],pas;
int n;

inline bool Full9(int poz)
{
    int i;
    for(i=poz;i<=last[0];++i)
        if(last[i]!=9) return false;
    return true;
}

inline bool Egal()
{
        int nrcif,i,limit,ok,scur,poz;
        nrcif=last[0];
        if(nrcif==1) limit=last[1]+1;
        else limit=last[1];
        if(limit==last[1] && Full9(2)) ++limit;
        for(i=limit;i<=9;++i)
            if(sum[pas]-i>=0 && sum[pas]-i<=9*(nrcif-1)) break;
        if(i==10) return false;
        ok=0;
        if(i>last[1]) ok=1;
        a[1]=i; scur=i;
        for(poz=2;poz<=nrcif;++poz)
        {
            if(ok) limit=0;
            else
                if(poz<nrcif)
                    limit=last[poz];
                else
                    limit=last[poz]+1;
            if(limit==last[poz] && Full9(poz+1)) ++limit;
            for(i=limit;i<=9;++i)
                if(sum[pas]-scur-i>=0 && sum[pas]-scur-i<=9*(nrcif-poz)) break;
            if(i==10) return false;
            if(!ok && i>last[poz]) ok=1;
            a[poz]=i; scur+=i;
        }
        last[0]=nrcif;
        for(i=1;i<=nrcif;++i) last[i]=a[i];
        return true;
}

inline void Solve()
{
    if(Egal()) return;
    int poz,i,scur,ok,nrcif;
    for(nrcif=last[0]+1,ok=1;nrcif<=100;++nrcif)
    {
        for(i=1;i<=9;++i)
            if(sum[pas]-i>=0 && sum[pas]-i<=9*(nrcif-1)) break;
        if(i==10) ok=0;
        a[1]=i; scur=i;
        for(poz=2;poz<=nrcif;++poz)
        {
            for(i=0;i<=9;++i)
                if(sum[pas]-scur-i>=0 && sum[pas]-scur-i<=9*(nrcif-poz)) break;
            if(i==10) ok=0;
            a[poz]=i; scur+=i;
        }
        if(ok)
        {
            last[0]=nrcif;
            for(i=1;i<=nrcif;++i) last[i]=a[i];
            return;
        }
    }
}

int main()
{
    int i,j;
    #ifndef ONLINE_JUDGE
        freopen ("date.in","r",stdin);
        freopen ("date.out","w",stdout);
    #endif
    cin.sync_with_stdio(0);
    cin>>n;
    for(i=1;i<=n;++i) cin>>sum[i];
    last[0]=1; last[1]=0;
    for(pas=1;pas<=n;++pas)
    {
        Solve();
        for(j=1;j<=last[0];++j) cout<<last[j];
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define Nmax 1000005
#define INF 2000000000
#define eps 0.000000000001

using namespace std;

int sum[Nmax],last[Nmax],a[Nmax],pas,ok[Nmax];
int n;

inline bool Ok(int nrcif, int suma)
{
    int i,j,scur;
    if(nrcif==0 && suma==0) return true;
    if(nrcif==0) return false;
    if(suma<0)  return false;
    for(i=1,scur=0;i<=nrcif;++i)
        for(j=0;j<=9;++j)
        {
            if(suma-scur-j>=0 && suma-scur-j<=9*(nrcif-i))
            {
                ok[i]=j; scur+=j; break;
            }
            if(j==10) return false;
        }
    if(scur==suma) return true;
}

inline bool Egal()
{
    int nrcif,pref,i;
    nrcif=last[0];
    for(pref=last[0]-1;pref>=0;--pref)
    {
        int aux=0;
        for(i=1;i<=pref;++i) aux+=last[i];
        for(i=last[pref+1]+1;i<=9;++i)
            if(Ok(nrcif-pref-1,sum[pas]-i-aux))
            {
                last[pref+1]=i;
                for(i=pref+2;i<=nrcif;++i) last[i]=ok[i-pref-1];
                return true;
            }
    }
    return false;
}

inline void Solve()
{
    if(Egal()) return;
    int poz,i,scur,ok,nrcif;
    for(nrcif=last[0]+1,ok=1;nrcif<=1000000;++nrcif)
    {
        ok=1;
        for(i=1;i<=9;++i)
            if(sum[pas]-i>=0 && sum[pas]-i<=9*(nrcif-1)) break;
        if(i==10) ok=0;
        a[1]=i; scur=i;
        for(poz=2;poz<=nrcif;++poz)
        {
            for(i=0;i<=9;++i)
                if(sum[pas]-scur-i>=0 && sum[pas]-scur-i<=9*(nrcif-poz)) break;
            if(i==10) ok=0;
            a[poz]=i; scur+=i;
        }
        if(ok)
        {
            last[0]=nrcif;
            for(i=1;i<=nrcif;++i) last[i]=a[i];
            return;
        }
    }
}

int main()
{
    int i,j;
    #ifndef ONLINE_JUDGE
        freopen ("date.in","r",stdin);
        freopen ("date.out","w",stdout);
    #endif
    cin.sync_with_stdio(0);
    cin>>n;
    for(i=1;i<=n;++i) cin>>sum[i];
    last[0]=1; last[1]=0;
    for(pas=1;pas<=n;++pas)
    {
        Solve();
        for(j=1;j<=last[0];++j) cout<<last[j];
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define Nmax 100005
#define INF 2000000000
#define eps 0.000000000001

using namespace std;

int sum[Nmax],last[Nmax],a[Nmax],pas,ok[Nmax];
int n;

inline bool Ok(int nrcif, int suma)
{
    int i,j,scur;
    if(nrcif==0 && suma==0) return true;
    if(nrcif==0) return false;
    if(suma<0)  return false;
    for(i=1,scur=0;i<=nrcif;++i)
        for(j=0;j<=9;++j)
        {
            if(suma-scur-j>=0 && suma-scur-j<=9*(nrcif-i))
            {
                ok[i]=j; scur+=j; break;
            }
            if(j==10) return false;
        }
    if(scur==suma) return true;
}

inline bool Egal()
{
    int nrcif,pref,i;
    nrcif=last[0];
    for(pref=last[0]-1;pref>=0;--pref)
    {
        int aux=0;
        for(i=1;i<=pref;++i) aux+=last[i];
        for(i=last[pref+1]+1;i<=9;++i)
            if(Ok(nrcif-pref-1,sum[pas]-i-aux))
            {
                last[pref+1]=i;
                for(i=pref+2;i<=nrcif;++i) last[i]=ok[i-pref-1];
                return true;
            }
    }
    return false;
}

inline void Solve()
{
    if(Egal()) return;
    int poz,i,scur,ok,nrcif;
    for(nrcif=last[0]+1,ok=1;nrcif<=1000;++nrcif)
    {
        ok=1;
        for(i=1;i<=9;++i)
            if(sum[pas]-i>=0 && sum[pas]-i<=9*(nrcif-1)) break;
        if(i==10) ok=0;
        a[1]=i; scur=i;
        for(poz=2;poz<=nrcif;++poz)
        {
            for(i=0;i<=9;++i)
                if(sum[pas]-scur-i>=0 && sum[pas]-scur-i<=9*(nrcif-poz)) break;
            if(i==10) ok=0;
            a[poz]=i; scur+=i;
        }
        if(ok)
        {
            last[0]=nrcif;
            for(i=1;i<=nrcif;++i) last[i]=a[i];
            return;
        }
    }
}

int main()
{
    int i,j;
    #ifndef ONLINE_JUDGE
        freopen ("date.in","r",stdin);
        freopen ("date.out","w",stdout);
    #endif
    cin.sync_with_stdio(0);
    cin>>n;
    for(i=1;i<=n;++i) cin>>sum[i];
    last[0]=1; last[1]=0;
    for(pas=1;pas<=n;++pas)
    {
        Solve();
        for(j=1;j<=last[0];++j) cout<<last[j];
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define Nmax 1000005
#define INF 2000000000
#define eps 0.000000000001

using namespace std;

int sum[Nmax],last[Nmax],a[Nmax],pas,ok[Nmax];
int n;

inline bool Ok(int nrcif, int suma)
{
    int i,j,scur;
    if(nrcif==0 && suma==0) return true;
    if(nrcif==0) return false;
    if(suma<0)  return false;
    for(i=1,scur=0;i<=nrcif;++i)
        for(j=0;j<=9;++j)
        {
            if(suma-scur-j>=0 && suma-scur-j<=9*(nrcif-i))
            {
                ok[i]=j; scur+=j; break;
            }
            if(j==10) return false;
        }
    if(scur==suma) return true;
}

inline bool Egal()
{
    int nrcif,pref,i;
    nrcif=last[0];
    for(pref=last[0]-1;pref>=0;--pref)
    {
        int aux=0;
        for(i=1;i<=pref;++i) aux+=last[i];
        for(i=last[pref+1]+1;i<=9;++i)
            if(Ok(nrcif-pref-1,sum[pas]-i-aux))
            {
                last[pref+1]=i;
                for(i=pref+2;i<=nrcif;++i) last[i]=ok[i-pref-1];
                return true;
            }
    }
    return false;
}

inline void Solve()
{
    if(Egal()) return;
    int poz,i,scur,ok,nrcif;
    for(nrcif=last[0]+1,ok=1;nrcif<=1000000;++nrcif)
    {
        ok=1;
        for(i=1;i<=9;++i)
            if(sum[pas]-i>=0 && sum[pas]-i<=9*(nrcif-1)) break;
        if(i==10) ok=0;
        a[1]=i; scur=i;
        for(poz=2;poz<=nrcif;++poz)
        {
            for(i=0;i<=9;++i)
                if(sum[pas]-scur-i>=0 && sum[pas]-scur-i<=9*(nrcif-poz)) break;
            if(i==10) ok=0;
            a[poz]=i; scur+=i;
        }
        if(ok)
        {
            last[0]=nrcif;
            for(i=1;i<=nrcif;++i) last[i]=a[i];
            return;
        }
    }
}

int main()
{
    int i,j;
    //#ifndef ONLINE_JUDGE
     //   freopen ("date.in","r",stdin);
       // freopen ("date.out","w",stdout);
    //#endif
    //cin.sync_with_stdio(0);
    cin>>n;
    for(i=1;i<=n;++i) cin>>sum[i];
    last[0]=1; last[1]=0;
    for(pas=1;pas<=n;++pas)
    {
        Solve();
        for(j=1;j<=last[0];++j) cout<<last[j];
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define Nmax 1005
#define INF 2000000000
#define eps 0.000000000001

using namespace std;

int sum[Nmax],last[Nmax],a[Nmax],pas;
int n;

inline bool Egal()
{
        int nrcif,i,limit,ok,scur,poz;
        nrcif=last[0];
        for(i=last[1];i<=9;++i)
            if(sum[pas]-i>=0 && sum[pas]-i<=9*(nrcif-1)) break;
        if(i==10) return false;
        ok=0;
        if(i>last[1]) ok=1;
        a[1]=i; scur=i;
        for(poz=2;poz<=nrcif;++poz)
        {
            if(ok) limit=0;
            else
                if(poz<nrcif)
                    limit=last[poz];
                else
                    limit=last[poz]+1;
            for(i=limit;i<=9;++i)
                if(sum[pas]-scur-i>=0 && sum[pas]-scur-i<=9*(nrcif-poz)) break;
            if(i==10) return false;
            if(!ok && i>last[poz]) ok=1;
            a[poz]=i; scur+=i;
        }
        last[0]=nrcif;
        for(i=1;i<=nrcif;++i) last[i]=a[i];
        return true;
}

inline void Solve()
{
    if(Egal()) return;
    int poz,i,scur,ok,nrcif;
    for(nrcif=last[0]+1,ok=1;nrcif<=100;++nrcif)
    {
        for(i=1;i<=9;++i)
            if(sum[pas]-i>=0 && sum[pas]-i<=9*(nrcif-1)) break;
        if(i==10) ok=0;
        a[1]=i; scur=i;
        for(poz=2;poz<=nrcif;++poz)
        {
            for(i=0;i<=9;++i)
                if(sum[pas]-scur-i>=0 && sum[pas]-scur-i<=9*(nrcif-poz)) break;
            if(i==10) ok=0;
            a[poz]=i; scur+=i;
        }
        if(ok)
        {
            last[0]=nrcif;
            for(i=1;i<=nrcif;++i) last[i]=a[i];
            return;
        }
    }
}

int main()
{
    int i,j;
    #ifndef ONLINE_JUDGE
        freopen ("date.in","r",stdin);
        freopen ("date.out","w",stdout);
    #endif
    cin.sync_with_stdio(0);
    cin>>n;
    for(i=1;i<=n;++i) cin>>sum[i];
    last[0]=1; last[1]=0;
    for(pas=1;pas<=n;++pas)
    {
        Solve();
        for(j=1;j<=last[0];++j) cout<<last[j];
        cout<<"\n";
    }
    return 0;
}