#include #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--) #define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++) #define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--) #define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++) #define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++) #define ALL(x) x.begin(), x.end() using ll = long long; using namespace std; pair fc(int a, int p){ int res = 1; while(a % p == 0){ res++; a /= p; } return {a, res}; } int main(){ int n, m, p; cin >> n >> m >> p; if(m == 1){ cout << 0 << endl; return 0; } vector> vt(n); ll now = 1; pair mx(0, 1); rep(i, n){ int in; cin >> in; now = max((int)now, in); auto [a, b] = fc(in, p); if(mx.first * b < a*mx.second){ mx = {a, b}; } } int ans = 1; while(now <= m){ ll nx = now * mx.first; ans += mx.second; if(nx <= now){ ans = -1; break; } now = nx; } cout << ans << endl; return 0; }