#include <bits/stdc++.h>   using namespace std;   vector<int> getPrimes(int n) {     vector<bool> sieve(n + 1, true);     sieve[0] = sieve[1] = false;     for (int i = 2; i * i <= n; i++)       if (sieve[i])         for (int j = i * i; j <= n; j += i) sieve[j] = false;     vector<int> primes;     for (int i = 2; i <= n; i++)       if (sieve[i]) primes.push_back(i);     return primes;   }   void storePrimes(int n, unordered_map<int, int> &m, vector<int> &primes) {     for (int p : primes) {       if (p * p > n) break;       while (n % p == 0) {         m[p]++;         n /= p;       }       if (n == 1) break;     }     if (n > 1) m[n]++;   }   void removePrimes(int n, unordered_map<int, int> &m, vector<int> &primes) {     for (int p : primes) {       if (p * p > n) break;       while (n % p == 0) {         m[p]--;         n /= p;       }       if (n == 1) break;     }     if (n > 1) m[n]--;   }   bool isAtleast(unordered_map<int, int> &m1, unordered_map<int, int> &m2) {     for (auto it = m2.begin(); it != m2.end(); it++) {       int num = it->first, freq = it->second;       if (m1.find(num) == m1.end() or m1[num] < freq) return false;     }     return true;   }   void printMap(unordered_map<int, int> &m) {     for (auto it = m.begin(); it != m.end(); it++)       cout << it->first <<  :   << it->second <<   n ;   }   long long int solve(int arr[], int n, int k) {     vector<int> primes = getPrimes(1000003);     unordered_map<int, int> mapK, currMap;     storePrimes(k, mapK, primes);     int i = 0, j = 0;     long long int count = 0;     while (j < n) {       storePrimes(arr[j], currMap, primes);       if (isAtleast(currMap, mapK)) {         while (i <= j and isAtleast(currMap, mapK)) {           count += (n - j);           removePrimes(arr[i], currMap, primes);           i++;         }       }       j++;     }     return count;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, k;     cin >> n >> k;     int arr[n];     for (int i = 0; i < n; i++) cin >> arr[i];     long long int ans = solve(arr, n, k);     cout << ans;     return 0;   }   