#include using ll=long long; using std::cin; using std::cout; using std::endl; using std::vector; int main(){ ll N,M,P; cin>>N>>M>>P; for(int i=2;i*i<=P;i++) assert(P%i); vector max(31,1); vector dp(601); dp[0]=1; ll biggest=0; while(N--){ ll X; cin>>X; biggest=std::max(biggest,X); ll cnt=0; while(X%P==0){ X/=P; cnt++; } max[cnt]=std::max(max[cnt],X); } for(int i=0;i<600;i++){ if(dp[i]*biggest>M){ cout<600) break; dp[i+j+1]=std::max(dp[i+j+1],dp[i]*max[j]); } } cout<<-1<