#include #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; int main(){ int n; lint m,p; scanf("%d%lld%lld",&n,&m,&p); vector a(n); rep(i,n) scanf("%lld",&a[i]); if(m==1){ puts("0"); return 0; } lint mx=*max_element(a.begin(),a.end()); if(mx>=m){ puts("1"); return 0; } lint mx2=1; for(lint x:a){ while(x%p==0) x/=p; mx2=max(mx2,x); } if(mx2==1){ puts("-1"); return 0; } lint tar=(m+mx-1)/mx; int cnt=0; for(lint x=1;x