#include<bits/stdc++.h>
using namespace std;
int n,m1,m2,s,minn=2e9;
struct node{
int num,cnt=0;//num 质因数 cut 质因子个数
}a[105];
int main(){
int idx=0;
cin>>n>>m1>>m2;
for(int i=2;i<=m1;i++){
if(m1%i0){
a[++idx].num=i;
while(m1%i0){
a[idx].cnt++;
m1/=i;
}
a[idx].cnt*=m2;
}
}
while(n--){
cin>>s;
bool f=true;
for(int i=1;i<=idx;i++){
if(s%a[i].num!=0){
f=false;
break;
}
}
if(f){
int maxx=0;
for(int i=1;i<=idx;i++){
int c=0;
while(s%a[i].num0){
c++;
s/=a[i].num;
}
int ans=(a[i].cnt-1)/c+1;
maxx=max(maxx,ans);
}
minn=min(maxx,minn);
}
}
if(minn2e9) cout<<-1;
else cout<<minn;
return 0;
}