import bisect from collections import defaultdict inf = 10 ** 18 N, M, P = map(int, input().split()) A = list(map(int, input().split())) if M == 1: print(0) exit() last = max(A) if last >= M: print(1) exit() WV = defaultdict(lambda: inf) for a in A: cnt = 1 while a % P == 0: a //= P cnt += 1 if a == 1: continue x = a cost = cnt while x < M: WV[x] = min(WV[x], cost) cost += cnt x *= a WV = list(WV.items()) WV.sort() item = [] for w, v in sorted(WV): while item and item[-1][1] >= v: item.pop() item.append((w, v)) ans = inf W, V = zip(*item) for w, v in item: ww = w * last if ww >= M: ans = min(ans, v + 1) continue target = (M + ww - 1) // ww i = bisect.bisect_right(W, target) for j in range(-1, 2): if 0 <= i + j < len(item) and ww * W[i+j] >= M: ans = min(ans, v + V[i+j] + 1) if ans >= inf: ans = -1 print(ans)