#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long a[200020]; int main() { long long n, m, p; cin >> n >> m >> p; long long m1 = m; long long ans = 10007; for (int i = 0; i < n; i++) { cin >> a[i]; int co1 = 1; while (a[i] % p == 0) { a[i] /= p; co1++; } m = m1; int co = 0; while (m >= 1) { if (co == 100) { co = 100007; break; } m /= a[i]; co++; } if (co * co1 < ans) { ans = co * co1; } } if (ans == 10007) { cout << "-1" << endl; } else { cout << ans << endl; } }