#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; vector max(61,1); vector dp(10001); 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<10000;i++){ if(dp[i]*biggest>M){ cout<1000) break; dp[i+j+1]=std::max(dp[i+j+1],dp[i]*max[j]); } } cout<<-1<