n,m,p,*a=map(int,open(0).read().split()) a.sort(reverse=True) for i in a: if i%p!=0 and i!=1: break x=1 for j in range(10**7): if x*max(a)>m: print(j+1) exit(0) x*=i x%=p print(-1)