import sys from operator import itemgetter sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) N,M,P = MI() A = LI() max_A = max(A) # 最後の1回の操作はmax_Aを掛ける X = M//max_A+1 # 目標値 if X == 1: print(1) exit() B = [] for a in A: r = 0 while a % P == 0: r += 1 a //= P B.append((r+1,-a)) # (操作回数,-(結局何倍になるか)) B = sorted(B,key=itemgetter(0,1)) C = [] r,a = B[0] a *= -1 C.append((r,a)) for i in range(1,N): r,a = B[i] a *= -1 if C[-1][0] < r and C[-1][1] < a: C.append((r,a)) for r,a in C: if a != 1: break else: print(-1) exit() dp = [1]*10000 # dp[i] = i回の操作でできる最大値 for i in range(1,10000): for r,a in C: if i >= r: dp[i] = max(dp[i],dp[i-r]*a) if dp[i] >= X: print(i+1) # 最後の1回の操作を追加 break