N,M,P=map(int,input().split()) A=list(map(int,input().split())) B=[] C=[] for i in range(N): B.append(A[i]) C.append(1) while B[i]%P==0: B[i]//=P C[i]+=1 Z=max(A) X=(M+Z-1)//Z if max(B)==1 and X>1: print(-1) exit() D=[[B[i],C[i]] for i in range(N)] D.sort(key=lambda x:((x[0]**10)**(1/x[1]))) P=0 Y=1 while Y*Z<=M: Y*=D[-1][0] P+=D[-1][1] print(P+1)