using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, m, p) = (c[0], c[1], c[2]); var a = NList; var max = a.Max(); var mul = new int[31]; foreach (var ai in a) { var tmp = ai; var count = 1; while (tmp % p == 0) { tmp /= p; ++count; } if (tmp > 1) mul[count] = Math.Max(mul[count], tmp); } var dp = new long[1000]; dp[0] = 1; for (var i = 0; i < dp.Length; ++i) { if (dp[i] * max > m) { WriteLine(i + 1); return; } for (var j = 1; j < mul.Length && i + j < dp.Length; ++j) if (mul[j] > 0) { dp[i + j] = Math.Max(dp[i + j], dp[i] * mul[j]); } } WriteLine(-1); } }